With PSexec tool, I am invoking a powershell session on remote computer and executing a PS1 script. I need to pass argument to this powershell script file. It works fine if the argument does not contain space. If the argument does contain space, everything after space is trimmed.
Below is my command:
$script="<PATH>"
$args = "%ProjectSourcePath%"
cmd /c %psexecpath% \\<REMOTE SERVER> -u <UNAME> -p <PASSWORD> -h "c:\windows\system32\windowspowershell\v1.0\powershell.exe" $script $args
where "%ProjectSourcePath%" is the environment variable.
Background: I am using this command in Jenkins Automated Build tool. And have added this script in Windows Powershell script block.
cmd /cwhen you can directly start the psexec?