I'm trying to launch a batch file in a cmd window on a remote machine using powershell.
This is my ps1 script.
function Run-BatchFile
{
param($computer = "mycomputer")
$batfilename = "mybatch.bat"
Invoke-Command -ComputerName $computer -ScriptBlock {param($batfilename) "cmd.exe /c C:\Batchfiles\$batfilename" } -ArgumentList $batfilename -AsJob
}
Run-BatchFile
When I run it from myhost machine I get this output..
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
5 Job5 RemoteJob Running True mycomputer param($batfilename) "c...
But no command prompt and batch file are launched on the remote machine.
Any clues as to what I am doing wrong or how to debug this as it looks like it works ok.
Thanks,
John.