When I pass the flags in a variable, as seen below, PsExec outputs the instructions as it does when there is a syntax error.
But, if I replace the $flags variable with “-s -h -d -nobanner” (without the quotes), it works fine. If I put quotes around the flags, it won’t work again. I assume it has a problem with strings. Can I typecast it to another type to get it to work?
$computer = "computer1" $flags = "-s -h -d -nobanner" $path = "C:\Windows\SysWOW64\explorer.exe" $arguments = ""
& .\PsExec.exe \\$computer $flags $path $arguments