I have a powershell command in a SQL job to call a remote batch file.
$sess=New-PSSession -ComputerName 'STVANFSS02.fnha.local' ;
invoke-command -scriptblock {C:\Scripts\FNPST\StartAppBat_Server_PST2.bat} -Session $sess ;
Remove-PSSession $sess;
When run it gives the following:
Executed as user: FNHA\SVC_PSInstall. The job script encountered the following errors. These errors did not stop the script: Unhandled Exception: System.FormatException: Index (zero based) must be greater than or equal to zero and less than the size of the argument list. at System.Text.StringBuilder.AppendFormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.FormatHelper(IFormatProvider provider, String format, ParamsArray args) at System.String.Format(IFormatProvider provider, String format, Object[] args) at Microsoft.SqlServer.Management.PowerShell.SqlPowerShell.GetErrorRecordMessage(ErrorRecord errorRecord) at Microsoft.SqlServer.Management.PowerShell.SqlPowerShell.HandleAgentJob(RunspaceConfiguration config) at Microsoft.SqlServer.Management.PowerShell.SqlPowerShell.Main(String[] args). Process Exit Code -532462766. The step failed.
Appreciate insight.