Hello,
I am hoping someone can help. I am in the process of converting our companies BATCH scripts to PowerShell. I use the COMMAND to call PowerShell & then the ARGS to pass the script path and arguments. The Simulation passed ESP, but the agent failed.
I guess my question would be, is it possible to use commas in the arguments? The script is in charge of restarting service on a couple of servers, and I setup an array in my PowerShell script to reduce the amount of lines in the code.
Here is what the spool file shows:
Output of messages for workload object QSVRTEST/SVRQNT.1/MAIN
Start date Thu Aug 16 22:21:34 2018
----------------------------------------------------------------
D:\SCRIPTS\SERVICERESTART\SERVICERESTART.PS1 : A parameter cannot be found that matches parameter name 'SVRSNAME
SERVER1,SERVER2 -SERVICENAME SPOOLER'.
+ CategoryInfo : InvalidArgument: (:) [SERVICERESTART.PS1], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : NamedParameterNotFound,SERVICERESTART.PS1
Here is what I have setup:
NT_JOB QSVRTEST +
LONGNAME(QSVR_RESTART_SERVICE_SPOOLER)
AGENT AGNT1
CMDNAME C:\WINDOWS\SYSTEM32\WINDOWSPOWERSHELL\V1.0\POWERSHELL.EXE
ARGS -FILE "D:\SCRIPTS\SERVICERESTART\SERVICERESTART.PS1" +
"-SVRSNAME SERVER1,SERVER2 -SERVICENAME SPOOLER"
RUN ANY
RESOURCE ADD(1,SVR_AGNT1_REN)
ENDJOB
Anyone help would be appreciated!
Thank you,
Mike