AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
$ProcessInfo.Password = $Credential.Password $ProcessInfo.Domain = $Credential.GetNetworkCredential().Domain $ProcessInfo.Username = $Credential.GetNetworkCredential().username #The next 3 lines are the credential for UserB, as you can see, we can't just pass $Credential $ProcessInfo.Arguments = "Get-Process Explorer" #The line below is basically the command you want to run and it's passed as text, as an argument $ProcessInfo.RedirectStandardOutput = $true $ProcessInfo.RedirectStandardError = $true $ProcessInfo.WorkingDirectory = $env:windir #Note the line below contains the Working Directory where the script will start from #CreateNoWindow helps avoiding a second window to appear whilst the process runs #With FileName we're basically telling powershell to run another powershell process #Use System.Diagnostics to start the process as UserB $Credential = Get-Credential itdroplets\UserB
0 Comments
Read More
Leave a Reply. |