Advertisement
Guest User

RunAs

a guest
Feb 22nd, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. $username = 'UsernameHere';
  2. $password = 'PasswordHere';
  3. $securePassword = ConvertTo-SecureString $password -AsPlainText -Force;
  4. $credential = New-Object System.Management.Automation.PSCredential $username, $securePassword
  5. Invoke-Command -ComputerName localhost -Credential $credential -ScriptBlock { commands go here }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement