Sunday, February 16, 2014

Powershell RunAs

Powershell run as:



                $p= New-Object -TypeName System.Diagnostics.Process
                $p.StartInfo.FileName="c:\temp\helloworld.exe"
                $p.StartInfo.UserName = "test"
                $p.StartInfo.Password = ConvertTo-SecureString -AsPlainText "testpassword" -Force
                $p.StartInfo.WorkingDirectory = "C:\Windows\System32"
                $p.StartInfo.UseShellExecute = $false
                $p.StartInfo.RedirectStandardOutput = $true
                $p.Start()
                $p.WaitForExit()
                $p.StandardOutput.ReadToEnd()

check also: http://stackoverflow.com/questions/18540505/powershell-processstartinfo-and-process-authentication-error

No comments:

Post a Comment