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 Experts,
Looking for a script that gives me all large files created on the server in the past 10 days..
should return file name, date created, size of file, user created.
Thanks in advance.
0
Get expert help—faster!
LVL 12
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

I set up a lot of operating systems (both Windows 10 and Server 2016) and currently spend quite a bit of time customizing the operating system doing things such as the following:

1. Changing the System Performance Options from "Let Windows choose what's best for my computer" to "Adjust for best performance"
2. Adding the Computer, My Documents, and Control Panel icons to the desktop
3. Pinning the Server manager, Command line (cmd.exe command), Control Panel, & PowerShell, Settings icons to the taskbar
4. Enabling System Protection and setting the amount of hard disk space to use to 13%
5. Enabling the "Allow remote connections to this computer" option, and enabling the local administrator account and the domain admin (administrator) account to remotely connect to the computer (within the Select Users option)
6. Setting the Power Options to "High Performance" and the "Choose when to turn off the display" to Never

I realize that a lot of these options can be set by googling what registry keys are created and or changed to do these things and then creating a PowerShell script (or even a batch file) to do these things but I'm also interested in finding ways where mouse movements and keyboard keystrokes can be recorded and then corresponding PowerShell commands created to do these things.

So what are the best software/methods for translating tasks into PowerShell scripts or for assisting me in creating these sort of PowerShell or automation scripts?
0
I need to create Server 2016 answer files for automating installations so that the installations can be unattended.

I need to be able to fill out information in advance to answer information such as the following during the automated installation:

- The administrator password
- The computer name of the server
- The domain the server will be joined to
- The Server 2016 product number installation serial number key
- The static IP address and DNS server addresses for the server
- The domain administrator username and password for joining the Server 2016 server to the AD domain

What are the best methods or utilities for creating such an unattended installation file?
0
Greeting Experts,

I need help setting up a PowerShell script to collect all of the Mac address currently blocked in DHCP ( i.e., Mac Filtering). My organization has some DHCP Server (over 60) located at each one of our sites. Can somebody help me create a script to query my companies Domain ( i.e., all the DHCP servers) and come back with a list of filtered mac addresses?  Can somebody help me with this task.... thanks
0
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
Experts,

I need a script that can take the contents of one text file and merge it with a second text file:

here are the specifics, I have worked most of it out but am stuck on 1 particular part.

Content1.txt
====== COA : Hyper-V Server list ======

> This page outlines the Company A Hypervisor Servers and their Respective Information.

Company A Hyper-V Servers:

^Server      ^IP Address   ^Chassis   ^Management IP^
|server1  |192.168.1.1  |||
|server2  |192.168.1.2  |||
|server3  |192.168.1.3  |||
|server4  |192.168.1.4  |K01|192.168.1.1|
|server5  |192.168.1.5  |K01|192.168.1.1|
|server6  |192.168.1.6  |K|192.168.1.1|
|server7  |192.168.1.7  |K|192.168.1.1|
|server8  |192.168.1.8  |K|192.168.1.1|
|server9  |192.168.1.9  |K|192.168.1.1|
|server10  |192.168.1.10|K|192.168.1.1|
|server11  |192.168.1.11|||
|server12  |192.168.1.12|||

Open in new window


content2.txt
====== COA : Hyper-V Server List ======

----

^Server      ^IP Address   ^Chassis   ^Management IP^
|[[:ict:servers:server1|SERVER1]]|192.168.1.1|||
|[[:ict:servers:server2|SERVER2]]|192.168.1.2|||
|[[:ict:servers:server3|SERVER3]]|192.168.1.3|||
|[[:ict:servers:server4|SERVER4]]|192.168.1.4|K01|192.168.1.1|
|[[:ict:servers:server5|SERVER5]]|192.168.1.5|K01|192.168.1.1|
|[[:ict:servers:server6|SERVER6]]|192.168.1.6|K|192.168.1.1|
|[[:ict:servers:server7|SERVER7]]|192.168.1.7|K|192.168.1.1|
|[[:ict:servers:server8|SERVER8]]|192.168.1.8|K|192.168.1.1|
|[[:ict:servers:server9|SERVER9]]|192.168.1.9|K|192.168.1.1|
|[[:ict:servers:server10|SERVER10]]|192.168.1.10|K|192.168.1.1|
|[[:ict:servers:server11|SERVER11]]|192.168.1.11|||
|[[:ict:servers:server12|SERVER12]]|192.168.1.12|||
\\

Open in new window



Code so far:

$content1 = get-content content1.txt
$content2 = get-content content2.txt
$Content1Base = $content1 |? {$_ -like "*|*"}
$content2base = $content2 |? {$_ -like "*|*"} 
$Content1Need = foreach ($_ in $content1base){(($_).split("|")|select -index 2,3,4) -join "|"}
$Content2Need = foreach ($_ in $content2base){(($_).split("|")|select -index 1,2) -join "|"}

$Neededoutput = write-host ($content2need)[1]"|"($content1need)[1]

Open in new window


Please take note of the $neededoutput.
[[:ict:servers:server2|SERVER2]] | 192.168.1.2  ||

I need to get this output across all 12 servers in the text file.
0
I have an old Windows 7 Workstation that belongs to a workgroup. It is responsible for 2 major functions that both require a separate drive mapping to 2 different servers on our Windows 2012 domain. The mappings are unstable and even though I check to reconnect box one or both manages to have a RED X every couple days. Security will not allow me to give the end user the password to the AD service account I use to map the drives. So everyone couple of days one of the major functions comes to a halt until I am contacted and if I am not available phones start ringing, emails start getting sent to my boss and you get the jest. I need a solution what I can give the end user that allows her a one click fix to remap. I know I can write a .bat file but am concerned I may need to hard code the password in the script which will be another security issue. Or is it possible to use local GPOs to unmap or remapped the drives each time the user logs in? I just need a quick and simple solution. Something very easy to fix gets escalated to a major issue real fast and I need a way to prevent this. All suggestions welcome even if it is different than a script of local GPO. BTW, I know I could put the workstation on the domain but that creates other issues with internet access one of the processes the device is used for....thanks
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'm at the beginner stage with powershell and after a new pc has been imaged i am trying to change PC name, join it to the domain and put it in the proper OU via powershell script.

param([string]$newpcname = (Read-Host 'Please enter new Computer name'))
Add-Computer -NewName $newpcname -DomainName test.ad.domain.com -Credential ad\domainadmin "OU=Test Machines, OU=Test Services, OU=Test LBs, OU=All LBs, DC=test, DC=ad, DC=domain, DC=com" -Restart

when I try this script i get the following error:

Add-Computer : Computer 'NewPC-test1' failed to join domain 'test.ad.domain.com' from its current workgroup 'TEST' with following error message: Access is denied.
At C:\Users\testuser\Desktop\Untitled2.ps1:4 char:1
+ Add-Computer -NewName $newpcname -DomainName test.ad.domain.com -Cred ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (NewPC-test1:String) [Add-Computer], InvalidOperationException
    + FullyQualifiedErrorId : FailToJoinDomainFromWorkgroup,Microsoft.PowerShell.Commands.AddComputerCommand

Can someone help me with this? Thanks!
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
Keep up with what's happening at Experts Exchange!
LVL 12
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

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
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 with "errstat" for specific errors related to SAS code conditions that I set up in my SAS code, and also check with "logerrchk" SAS log file for any errors in the SAS log.  
I think most of the script is correct but I am not sure about both checking errors (errstat" and "logerrchk").

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

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

#!/bin/bash
#script1.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

#executing SAS program
sas ${PROGDIR1}/program1.sas -log ${DATADIR3}/program1.log

#checking for errors in SAS log file
logerrchk=$?     
   if [[ "$logerrchk" !=0 ]]; 
   then 
       echo "--- Error: Abnormal end in program program1.sas. Check log file! ---" >> $plog
       exit 2
   else
       echo "--- Program1.sas run successfully! ---" >> $plog
   fi
  
#checking for specific errors 

Open in new window

0
Hi All

Using Microsoft SQL 2016, I built the below script

DECLARE @startdate datetime
DECLARE @enddate datetime
DECLARE @facility varchar(8000)


SET @startdate = '2018-01-01'
SET @enddate = '2018-01-30'
SET @facility = 'PENRITH,GOLDCOAST,PERTH'

	------------------------------------------------------------------------
	SELECT
	 CAST(t.trans_no  as varchar(100))								as [Transaction Number]
	,CAST(t.invoice_no  as varchar(100))							        as [Invoice Number]
	,inv.account													as [Account Name]
	,act.acct_type												as [Account Type]
	,ty.descrip													as [Account Description]
	,CAST(r.reserv_no as varchar(100))								as [ Reservation Number]
	,t.orig_dt														as [Booking Date]
	,t.start_date													as [ Date]
	,DATENAME(DW,T.start_date)									as [ Day of Week]
	,DATEDIFF(DAY,t.orig_dt,t.start_date)							as [Days Booked to ]
	,t.department												as [ Product Hierarchy]
	,t.category													as [Category]					
	,i.descrip													as [ Product Name]
	,t.special														as [Special]
	,mk.descrip													as [Marketing Code]
	,t.quantity													as [Quantity]
	,CAST(t.pts4qty  as varchar(100))								as [Minutes]	
	,address.zip													as [Postcode]
	,au.region1													as [State]
	------------------------------------------------------------------------
	,t.tax_amount													as [GST]
	,t.extension/1.1												as [ Revenue]
	

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
Hello,
I would like to have a logon script that I would put in my active directory users.
This script shoud:
1. Create a folder at a network place \\cadc03\timesheets\first name and name of the user (taken from AD)
2. Map this folder in the user profile.

Ofcourse if the folder already exists, it should disregard the first step.
Thank you.
0
Hi, I would like to run a script on my DC to get a list of users/groups who have permissions to change AD password for users.

How can I obtain these results? I would like to avoid going through each OU/sub OU and check delegation/security settings.

Thanks all.
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
Cloud Class® Course: Microsoft Exchange Server
LVL 12
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

Hello all,

I am working on a script to install application, it works good. but the setup file need to have some permissions on folder in C.
what can I include in the script to modify permission of particular folder?

Regards
0
I have powershell codes and working okay with 1 attachment.
How can I add all three attachment into this powershell?

The goal is to use this powershell to send 3 attachments in one email.

Thanks
$Username = "smtp";
$Password = "Fire";
$path01 = "E:\Reports\AgentSummary\Agent-Sales-Summary1.xls";
$path02 = "E:\Reports\AgentSummary\Agent-Sales-Summary2.xls";
$path03 = "E:\Reports\AgentSummary\Agent-Sales-Summary3.xls";

function Send-ToEmail([string]$email, [string]$attachmentpath){

    $message = new-object Net.Mail.MailMessage;
    $message.From = "IT@s.com";
    $message.To.Add($email);
    $message.Subject = "Agent Sales Summary Report";
    $message.Body = "Agent Sales Summary Report. Please review the attached file. Thank You";
    $attachment = New-Object Net.Mail.Attachment($attachmentpath);
    $message.Attachments.Add($attachment);

    $smtp = new-object Net.Mail.SmtpClient("smtp.sendgrid.net", "587");
    $smtp.EnableSSL = $true;
    $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
    $smtp.send($message);
    write-host "Mail Sent" ; 
    $attachment.Dispose();
 }
Send-ToEmail  -email "sales@receiverxxx.com" -attachmentpath $path01;

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
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

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.