Advertisement
Guest User

Untitled

a guest
Sep 5th, 2017
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. $username = "username"
  2. $password = "password"
  3. $startWithElevatedRights = "notepad"
  4.  
  5. $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
  6. Start-Process powershell -Credential $credentials -ArgumentList '-noprofile -command &{Start-Process ‘, $startWithElevatedRights, ‘ -Wait -verb runas}'
  7.  
  8. $username = "username"
  9. $password = "password"
  10. $startWithElevatedRights = "notepad"
  11.  
  12. $credentials = New-Object System.Management.Automation.PSCredential -ArgumentList @($username,(ConvertTo-SecureString -String $password -AsPlainText -Force))
  13. $ps = Start-Process -PassThru -FilePath powershell -Credential $credentials -ArgumentList '-noprofile -command &{Start-Process ', $startWithElevatedRights, ' -Wait -verb runas}'
  14.  
  15. $ps.WaitForExit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement