Guest User

Untitled

a guest
Feb 8th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. $Computer = Read-Host "Computer name:"
  2. $UserName = Read-Host "User name:"
  3. $Password = Read-Host "Password" -AsSecureString
  4. $AdminGroup = [ADSI]"WinNT://$Computer/Administrators,group"
  5. $CompObject = [ADSI]"WinNT://$Computer"
  6. $User = $CompObject.Create('User',$UserName)
  7. $Cred = New-Object -TypeName System.Management.Automation.PSCredential -
  8. ArgumentList $UserName, (ConvertTo-SecureString $Password -AsPlainText –
  9. Force)
  10. $User.SetPassword($Cred.GetNetworkCredential().Password)
  11. $User.SetInfo()
  12. $AdminGroup.Add($User.Path)
Add Comment
Please, Sign In to add comment