Scripting Languages

27K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

Share tech news, updates, or what's on your mind.

Sign up to Post

Hi,

I have used following script to get report new created AD user in Active directory with last 7 days.  

$When = ((Get-Date).AddDays(-7)).Date
Get-ADUser -Filter {whenCreated -ge $When} -Properties whenCreated | Export-csv -path c:\ADLastUserCreated.csv

But Head of IT wants  me to create script  and schedule to run every 8 hours and send email on distribution group to see the report new AD created user.

i am just learning power-shell  now days and getting on this. please  Can I have help on this how to create script to genrate report and email to certine distribution group that shows last day list of AD  user created.



thanks in advance.

Regards
Asif
0
Cloud Class® Course: Microsoft Office 2010
LVL 12
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

Hello experts,
I am looking for two batches that
1-delete /f based on a csv file.
2-rmdir /q /s based on a csv file.

-Full path of files to delete and remove directory will be reported in column a
-Two different batches or CMD and CSV files one for rmdir.csv and the other del.csv.

Logs files should be generated in order to check what has been removed.
Rmdir just remove reported folder and not parent folder.
/S option should be set up to remove subdirectories of reported folders.
 If you have questions please contact me.
0
Hey Experts.  I am trying to copy a file from the server's share to a remote pc via a powershell script.  When I run the script in the ISE, I continue to get an error:

Copy-Item : Could not find a part of the path '\\etu4r\c$\Program Files\uvnc bvba\UltraVNC'.
At line:1 char:1
+ Copy-Item -path '\\w2k12fs01\public\ultravnc.ini' -destination '\\etu4rc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], DirectoryNotFoundException
    + FullyQualifiedErrorId : System.IO.DirectoryNotFoundException,Microsoft.PowerShell.Commands.CopyItemCommand

Using this script:
$remotepc=read-host -prompt 'Computer Name'
$servicename="uvnc_service"
$source='\\w2k12fs01\public\ultravnc.ini'
$destination='\\$remotepc\c$\Program Files\uvnc bvba\UltraVNC'

Copy-Item -path $source -destination $destination -Force

Open in new window


I am launching this under my credentials which is a domain admin level.  Server is Windows 2008 R2 and we have Windows 7 Ent on all desktops.  I've tried different file copy commands including from the command line with just copy-item and replacing variables with the actual value.  I would greatly appreciate your help getting this to work.  Thanks Experts.
0
I followed a simple tutorial on how to schedule console applications (exe ) on windows scheduler. I came across "Puppet" and how it can be used to manage/configure such applications.
what is puppet and how can it be used  ?
0
Experts, I am drawing a blank here and know I am missing something simple.

Location1servers file
<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
<Obj RefId="0">
    <S>SERVER1</S>
    <MS>
      <S N="Name">SERVER1</S>
    </MS>
  </Obj>
  <Obj RefId="1">
    <S>SERVER2</S>
    <MS>
      <S N="Name">SERVER2</S>
    </MS>
  </Obj>
</Objs>

Open in new window


\\$L1S\C$\Zabbix\cec\ZabbixDeployment\zabbix_agentd.win.conf"
ComputerName = Server1
Hostname = Server1 
UserParameter= Some information 

Open in new window



$location1servers = Import-clixml location1servers.xml
foreach ($L1S in $Location1Servers){
$configtemp1 = @(get-content "\\$L1S\C$\Zabbix\cec\ZabbixDeployment\zabbix_agentd.win.conf")
$configsearch1 = $configtemp1 |? {$_ -like "Hostname=*"}
$Location1Servers += $Location1Servers|? {$_ -like $L1S} |select-object @{n= 'ComputerName'; e= {$_}}, @{n= 'HostnameConfig';e= {$configsearch1}}, @{n= 'UserParameter';e= {$configsearch1a}} |select ComputerName, "HostnameConfig", UserParameter
}

Open in new window


$location1servers |out-gridview



When I run this code, I get the following output:

output1.png

Any help would be greately appreciated.

I am looking for ComputerName, Hostname, and UserParameters to be their own separate rows rather inbedded into a single row.
0
Dear expert

Check the code below.
I would like to grab all the lines that start with 01. But below code didn't really do it... I don't know why tho... $Pattern.substring(0,1) this would work?

Thanks

#$time = ((Get-Date).Addmonths(-3))
$path =  "D.\27\sus","D:\65\sus","D:\56\sus"
$Pattern = "01"

$results = Get-ChildItem -Path $path -Recurse -File |
	Select-String -Pattern $Pattern.substring(0,1) | #where-object {$_.Time -gt $time} |
	Group-Object Path |
	% { #Foreach-object alias
		$_.Group | Select-Object Line , path | Format-List 
	
}
if ($Pattern) {
$results | Out-File d:\test\result.txt
[System.Windows.MessageBox]::Show('Search is done','Error')
}

Open in new window

0
People,

I need some assistance to modify the below script so it runs with specific filtering on certain OU:

<#
Created by: https://www.experts-exchange.com/members/oBdA.html
.SYNOPSIS
Gets a list of accounts used in services and tasks.
.DESCRIPTION
Gets a list of accounts used in services and tasks. Default Windows accounts will be filtered out.
.PARAMETER ComputerName
A list of computer names to query.
You can pipe strings to this argument.
.PARAMETER Filter
A list of strings with account names to look for; overrides the default filter.
Note that accounts may show up as DnsDomainName\User, NetBiosDomainName\User, or user@DnsDomainName.
.PARAMETER ServiceOnly
Process only services.
.PARAMETER TaskOnly
Process only tasks.
.INPUTS
System.String
.OUTPUTS
System.Management.Automation.PSCustomObject
.EXAMPLE
Get-ServiceOrTaskAccount
.EXAMPLE
Get-ServiceOrTaskAccount -ComputerName SomeMachine, SomeOtherMachine -ServiceOnly
.EXAMPLE
Get-Content .\servers.txt | Get-ServiceOrTaskAccount -Filter "Domain\Administrator", "Administrator@domain.com"
#>
#requires -Version 3
[CmdletBinding(DefaultParameterSetName="Get_Service_Task")]
Param(
	[Parameter(Mandatory=$false, Position=0, ValueFromPipeline=$True)]
	[string[]]$ComputerName = @($ENV:ComputerName),
	[string[]]$Filter,
	[Parameter(Mandatory=$false, ParameterSetName="Get_Service")]
	[switch]$ServiceOnly,
	[Parameter(Mandatory=$false, ParameterSetName="Get_Task")]
	[switch]$TaskOnly
)
Begin {
	$IgnoreAccounts = @()
	ForEach 

Open in new window

0
I have a php webpage and I need to run a exe with command I tried different ways but no luck somebody can share a script for this? or which is the best  way to do this?
0
I had this question after viewing batch findtext match 2 criteria.
i am still playing with the above, however now i am having an issue while searching a csv i need to look for "DS" & "DSA" including the ", is there a way to accomplish this using findstr
perhaps with a double "
/c:"""ds"""

Open in new window

0
Hi everyone!
I am trying to do a few things in my bash script (script1.sh):  pass logicals/variables to my SAS program (program1.sas), execute SAS code (program1.sas), check for errors, write all messages to a log file (sas_program.log), and also execute another script (script2.sh) which has a few directory logicals/variables shortcuts.

Please note: variable/logicals (file1, file2, plog, and stat) are also defined in the SAS program.  

Please provide any suggestions or examples if you can.
Here is what I have so far:

#script1.sh

#!/bin/bash

#executing script2.sh script 
source script2.sh

# Creating variables for directories
export DATADIR1=/root/alldirs/2018/data1
export DATADIR2=/root/alldirs/2018/data2
export DATADIR3=/root/alldirs/2018/data3
export PROGDIR1=/root/alldirs/2018/prog1


#Creating variables for data files that are used in program1.sas and final log file 
export file1=DATADIR1/sasdata1.sas7bdat
export file2=DATADIR2/sasdata2.sas7bdat
export plog=DATADIR3/sas_program.log

#Setting stat variable for future use
stat=0

#executing SAS program, checking for errors, and writing all messages to a log file 
sas ${PROGDIR1}/program1.sas -log ${DATADIR3}program1.log
stat=$?
   if [[ "$stat" !=0 ]]; 
     then echo -e "--- Error: Abnormal end in program program1.sas. Check log file! ---" >> $plog
    exit 2
             echo -e "--- Program1.sas run successfully! ---" >> $plog
   fi
exit 0

Open in new window




Any suggestions would be appreciated!
Thank you!
0
Cloud Class® Course: Microsoft Azure 2017
LVL 12
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

Need a custom script to scan text files and return results. I have a UNC path to a text file. A new file is created every day. I need to scan the file for any lines that contain the text 'JUMPBY' and export those lines to a new text file so that I can see a final report only containing the lines that were found. Let me know if you need more details and thanks for the help!
0
How to design and implement virtual labs for student login on a website? Is there an easy method to deloy virtual lab technology to allow multiple user login and have the virtual lab build the same way each time say for exam lab 1 builds a specific type of vm and runs scripts to deploy specific windows features etc. I found a great layout that I would like to base this project off of and that is the virtual labs for MCSA server 2012 R2 from cbt nuggets if anyone is familiar with their virtual lab option Ill explain a bit

Virtual lab 1 Configuring server
Click link and it builds in the web browser a client and 4 servers to utilize in the lab

I'm assuming this is being done with behind the scenes scripts and in the cloud for the resources that are being shared. Does anyone have a guide or has built something similar to this setup
0
People,

Based on the builtin PowerShell command
Resolve-DnsName -Name bing.com -Type NS -DnsOnl

Open in new window


I need some help in fixing or modifying my PowerShell script below to perform:

1. Get the public IP address of the domain names in the .TXT file (or .CSV)
2. Get the DNS server responsible for the domain in the input .TXT file
3. Export the list as .CSV like below:

DomainName, PublicIP, DNS Server (NameHost)
www.domain1.com, 134.13.123.22, NS1.domain1.com
www.domain1.com, 134.13.123.25, NS2.domain1.com
www.domain2.com, 201.52.234.1, NS1.domain2.com

$InputFile = 'C:\Domainlist.txt'
$addresses = get-content $InputFile
$reader = New-Object IO.StreamReader $InputFile
while ($reader.ReadLine() -ne $null) { $TotalRecords++ }
write-host    ""
write-Host "Resolving DNS on each domain..."
foreach ($address in $addresses)
{
	## Progress bar
	$i++
	$percentdone = (($i / $TotalRecords) * 100)
	$percentdonerounded = "{0:N0}" -f $percentdone
	Write-Progress -Activity "Performing DNS Resolve" -CurrentOperation "Working on domain: $address (IP $i of $TotalRecords)" -Status "$percentdonerounded% complete" -PercentComplete $percentdone
	## End progress bar
	try
	{
		Resolve-DnsName -Name $address -Type NS -DnsOnly
	}
	catch
	{
		Write-host "$address was not found. $_" -ForegroundColor Green
	}
}
write-host    ""
write-Host "Pinging each address..."
foreach ($address in $addresses)
{
	## Progress bar
	$j++
	$percentdone2 = (($j / $TotalRecords) * 100)
	

Open in new window

0
hello,

we have a partner puch contact with FIM to our Active Directory.
after that, i use a small powershell code to activate external contact on our Exchange 2013 :

Get-Contact -OrganizationalUnit "OU=XXX,OU=Contacts,DC=CONTOSO,DC=com" -resultsize unlimited| foreach { Enable-MailContact -Identity $_ -Alias ($_.firstName+"."+$_.lastName) -ExternalEmailAddress $_.WindowsEmailAddress.toString() -PrimarySmtpAddress $_.WindowsEmailAddress.toString() }

Open in new window


the problem is some contact have not firstname or lastname, and other have firstname or last name with space like firstname= "Jean Denis" and the script fail.

instead of building the alias with  ($_.firstName+"."+$_.lastName), i need to build the alias with WindowsEmailAddress   attribute but without the @domain.com,

here an exemple of a contact before i enable it on exchange:

[PS] D:\Get-Contact von-si.ong@externaldomain.com |fl


RunspaceId               : b4805db4-76aa-460f-bf4e-b9da3ca4d5a5
OrganizationalUnit       : contoso.com/Contacts
AssistantName            :
City                     : XXXXXX
Company                  : XXXXXXXX
CountryOrRegion          :
Department               : XXXXXXXX
DirectReports            : {}
DisplayName              : ONG Von Si (xxxx)
Fax                      :
FirstName                : Von Si
GeoCoordinates           :
HomePhone                :
Initials                 :
LastName                 : ONG
Manager                  :
MobilePhone              :

Open in new window

1
I try to use a dos batch script which I found in internet but it does not work. I have only adjusted the two “set  scriptname= …” and “set prodir=…”
---
The script look like this:
@echo off
 
REM set to location of this script
REM +++ set scriptname=<XXX>\purgeall.bat +++
set scriptname="C:\Users\top\Desktop\purgeall.bat"
REM set to pro/engineer loadpoint
REM +++ set prodir=<Pro/ENGINEER Load Point> +++
set prodir="C:\Program Files\PTC\Creo 4.0\M030\Parametric"
if "%1" == "purge" goto p2
cls
call %prodir%\bin\purge.bat
echo.
FOR /D /R "D:\PTC\Gast\Test_1" %%a IN (*.*) DO call %scriptname% purge "%%a"
 
:p2
cd %2
echo Purging %2.
echo.
call %prodir%\bin\purge.bat
---

I get this error message in windows 7 64 bits ultimate in a cmd window when I start the batch program in that cmd window:
The command “C:\Program” is either wrong written or it is not possible to find
(I have translated the error message from German to English)
What have I done wrong to use this script?
The sub batch program purge.bat works if I use it direct in the cmd window.
0
Hi,

I have a text file where I want to combine the first and second row into one row. How do I do it using the
Do Until objFile.AtEndOfStream
Loop



Thanks
SampleData.txt
what-is-needed.png
0
I'm looking for a powershell script that exports security logs with Event ID 4740.
I'm new to powershell and failed to find any on Google.

Thanks for your support!
1
Hi Experts,

I would like to have a function that merges two records as follows.

we want all data of both records to be saved under one record.

function should have two params EmpID1 and EmpID2.

Goal = all data should be consolidated into EmpID1.

Lets say we have table named Employeestbl with dozens of fields of all types, some are nvarchar, some are dates etc..

function should loop thru all table fields and will check if fieldtype is nvarchar or int or anything but datetime, then if one record has field null and the other one has data then update (EmpID1) with that data.

If datatype is date then in addition to the above, if both has data should check which has later date and update to that.

How is that possible?

Thanks in advance.
0
This works:

do shell script "cURL -f http://mydomain/myfile.txt -o ~/Library/'Group Containers'/UBF8T346G9.Office/myFile.txt"

Open in new window

But extending the target path to include a second quoted folder fails:

do shell script "cURL -f http://mydomain/myfile.txt -o ~/Library/'Group Containers'/UBF8T346G9.Office/'User Content'/myFile.txt"

Open in new window

It raises an err:

Warning: Failed to create the file /Users/[username]/Library/Group

And in both cases, wrapping the full path in single quotes also fails at the same "Group" part of the path, eg:

do shell script "cURL -f http://mydomain/myfile.txt -o '~/Library/Group Containers/UBF8T346G9.Office/myFile.txt'"

Open in new window

What am I doing wrong?
0
Cloud Class® Course: CompTIA Healthcare IT Tech
LVL 12
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

I have an AppleScript that is used to programmatically create a test script file in one of these Office 2016 app folders:

~/Library/Application Scripts/com.microsoft.Excel
~/Library/Application Scripts/com.microsoft.Word
~/Library/Application Scripts/com.microsoft.Powerpoint

This is the test.scpt file content which is programmatically generated:

on handlerTest(thisPhrase)
	say thisPhrase
end handlerTest

Open in new window


This test.scpt file contains a single handler which speaks the phrase passed to it.

When the script is created in one of these folders, I cannot see the content of the script file in Finder and calling the handler from a Microsoft Office app using the new VBA AppleScriptTask causes the Office app to crash. I think the script is being created as a byte-compiled file because it cannot be viewed in Finder as plain text.

If I then copy the script file generated programmatically by my script creator script to the Documents folder, the plain-text content of the script is viewable in Finder.

Now, if I copy the script file from the Documents folder back to the corresponding com.microsoft folder (without modifying it), I can now see the plain-text content in Finder and calling the handler using the VBA AppleScriptTask function works as expected. I don't understand how the format is apparently changing due to copy/paste actions?

How can I programmatically create the script file in the com.microsoft.xyz folder in plain text format?

Here is my VBA procedure:


Open in new window

0
hello,
i use this command to send a print job to our printer for specific user

for that i use the username and password of user and psexec, after that the user can go to the printer and us his badge to print the document.

PsExec.exe -u domain\userName -p password cmd.exe /c print /d:\\printserver\Queue_color C:\print\test.txt

this is send a job to our printer, when i go to the printer to print this job, i see remote downlovel document for the file name, and printer wont print it.

in our old printer xerox, this is work, but with our new canon not work.

maybe you can suggest other simple way to print a document ? i test out-printer locally and it work, but i dont now if i can use it with psexec?

thanks for help
0
Hello Experts:

I have a text file that I need to:

1) DELETE all asterisks at the end of each row if any.

2) COMBINE all rows with tilde

See attached excel file and Original and New .txt files.


I have a vbs script file that will convert from one row with tilde to different rows. See attache vbs file.

Please help.

Thank you again for all your help.
Delete1st_and_Combine2ndwithTilde.xlsx
Original_320048803_15172018.txt
New_320048803_15172018.txt
ReformatUnixText.vbs
0
I need a batch (ie .bat or .cmd) logon script that will check if the hostname is one of the 20
& if so, then only execute a series of commands on the PC.  The pseudo code will be like:

if %computername%="host1"  or ... or %computername%="host20"
then
   (
    command 1
    command 2
   )

Basically I need to get the syntax right
0
Dear expert

I would like to build a script that do the server audit like this:
$Servers = Get-Content C:\temp\serverlist.txt
$result = Foreach ($server in $Servers) { gc "$server"       
}
if ($server-ne $null){write-host "File in $Server"}
}
The operation is simply check the server list in the txt files, if there is any files under the path list, write-host file in path.
Code above is not working as planned, the result always show the last line of the serverlist txt got a file in it and I checked, there is no files.
Any ideas?
0
hi, please refer to the:
https://www.experts-exchange.com/questions/29066306/xlsx-xls-csv-conversion.html
thread
Bill Prew gave me the solution for converting my excel files on UTF-8 CSV (thanks again, Bill! :=))

Const xlCSV = 6
Const xlTex = -4158
Const xlTextWindows = 20
Const msoEncodingUTF8 = 65001

strDir = "C:\Perl64\eg\alma\files"

Set objFSO = CreateObject("Scripting.FileSystemObject")

With CreateObject("Excel.Application")
    .Visible = False
    .DisplayAlerts = False

    For Each objFile In objFSO.GetFolder(strDir).Files
        strExt = objFSO.GetExtensionName(objFile.Path)
        If LCase(Left(strExt, 3)) = "xls" Then
            Wscript.Echo "Reading file: [" & objFile.Path & "]"
            With .Workbooks.Open(objFile.Path, False, True)
                With .Sheets(1)
                    .Rows(1).Delete
                    .Columns(1).Delete
                End With
                strPath = Replace(objFile.Path, "." & strExt, ".csv")
                Wscript.Echo "Writing file: [" & strPath & "]"
                .WebOptions.Encoding = msoEncodingUTF8
                .SaveAs strPath, xlTextWindows
                .Close False
            End With
        End If
    Next

    .Quit
End With

Set objFSO = Nothing

Open in new window



but I've noted that the UTF-8 conversion doesn't always works well.
Please see a sample enclosed: a french address "converted" utilizing the OpenOffice Calc csv-UTF-8 conversion (openOffice.jpg) and  the same address "converted" using the script (excel2013.jpg).
You can see the presence of the double commas "" and an unsatisfactory rendering of some letters on the Excel conversion.
maybe that I need some patch to my (old) 2013 Excel? or should definitively upgrade to a more recent version?

Thanks,
Fabiano
excel2013.jpg
openOffice.jpg
0

Scripting Languages

27K

Solutions

20K

Contributors

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.