Is there a way to run a command in a specific Command Prompt window using its Process ID?
$command = "C:\Windows\system32\cmd.exe" $ID = (Start-Process -FilePath $Command -PassThru).Id Write-Host $ID $command = "mycommandgoeshere" $process = Get-WmiObject Win32_Process -Filter "ProcessId=$ID" $process.InvokeMethod("Create", $command) However, it is failing with the error
NotSpecified: Exception calling "InvokeMethod" with "2" argument(s): "Invalid method "
I'm looking for a way to run commands on a remote server in the same command window. Thank you!
CMDat all to run commands on a remote machine at all, you know that, right? Regardless of that - why did you add the tags for different PowerShell versions? Are you asking for a specific version? If not you should remove these tags. Thanks in advance. 👍🏼