Start-process raises an error when providing Credentials – possible bug

I have the same bug. This function is OK with Powershell ISE, but doesn’t work with PowerGUI Start-Process -FilePath “C:\WINDOWS\System32\cmd.exe” -Credential $credential -ArgumentList (“/c $sFileExecutable”) It works with the WorkingDirectory parameter Start-Process -FilePath ‘cmd.exe’ -Credential $credential -ArgumentList (“/c $sFileExecutable”) -WorkingDirectory ‘C:\Windows\System32’

Is there a way to pass serializable objects to a PowerShell script with start-process?

Yes. As PetSerAl wrote in a comment, you can use the PSSerializer class to handle that: $ser = [System.Management.Automation.PSSerializer]::Serialize($credential) $cred = [System.Management.Automation.PSSerializer]::Deserialize($ser) I don’t know if your process will understand the CliXML format though; you don’t specify what process you’re starting. Since this will produce XML which is multi-line, it may not work to pass … Read more

Capturing standard out and error with Start-Process

That’s how Start-Process was designed for some reason. Here’s a way to get it without sending to file: $pinfo = New-Object System.Diagnostics.ProcessStartInfo $pinfo.FileName = “ping.exe” $pinfo.RedirectStandardError = $true $pinfo.RedirectStandardOutput = $true $pinfo.UseShellExecute = $false $pinfo.Arguments = “localhost” $p = New-Object System.Diagnostics.Process $p.StartInfo = $pinfo $p.Start() | Out-Null $p.WaitForExit() $stdout = $p.StandardOutput.ReadToEnd() $stderr = $p.StandardError.ReadToEnd() Write-Host … Read more