question

TBingeman avatar image
0 Votes"
TBingeman asked TBingeman published

Need help running multiple scripts with parameters at the same time

So I have 17 scripts that I need to run to clear some vulnerabilities within our network. Each of these scripts can be run on a single server, or use a csv or txt file with a list of servers in it. I am trying to write a script that will run the 17 scripts and pass the -ServerFileList parameter to each script. In the end, each script will have a specific txt file for that script to use so there will be 17 different lists of servers. When I run the below code, a PowerShell window will open but then close right away without running the script. These scripts will be run on Wednesday 7-14-21 at 3 PM PST so I need to get this figured out before then or I will have to hard code the -ServerFileList parameter into each script. Any help you all can provide will be greatly appreciated.

 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-3PCookies. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-AdobeJS. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-AnonEnum. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-Autofill. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-Autoplay. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-Autorun. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-ConfOfferRA. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-ElevReq. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-EnumAdminAccts. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-IEInvalidSig. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-IEOutdatedActivex. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-InstallElevated. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-NetworkBridge. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-OutdatedPlugins. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-SolicitedRA. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-WinRMClientBasicAuth. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-WinRMServiceBasicAuth. -ServerFileList "c:\scripts\disable item\Servers Test.txt"'
windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered TBingeman published

Hi,

It seems the "ps1" extension is missing. Please check to see if this works.


 Start-Process PowerShell.exe -ArgumentList '-File "c:\scripts\disable item\Disable-3PCookies.ps1" -ServerFileList "c:\scripts\disable item\Servers Test.txt"'


Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

OK so I verified that the .ps1 extension was in the script I was testing in the ISE but was missing in my Notepad++ document. When I ran the line you provided adding in -noexit to the arguments, I get the error below.

 C:\scripts\disable item\Disable-3PCookies.ps1 : A parameter cannot be found that matches parameter name
 'ServerFileList'.
     + CategoryInfo          : InvalidArgument: (:) [Disable-3PCookies.ps1], ParentContainsErrorRecordException
     + FullyQualifiedErrorId : NamedParameterNotFound,Disable-3PCookies.ps1

I then checked and verified that the param() block had the parameter listed.

 param(
  [Parameter(Mandatory=$False, HelpMessage="Path to a .csv or .txt file with a list of servers (no header)")]
     [string]$ServerListFile = $null,
  [Parameter(Mandatory=$False, HelpMessage="Name of a computer")]
     [array]$ComputerName = $null
 )

This is when I realized where my mistake was. Apparently I mistyped my parameter as -ServerFileList when it should have been -ServerListFile. Thank you for your help in finding my errors in the script.

0 Votes 0 ·