Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $Computer = Read-Host "Computer name:"
- $UserName = Read-Host "User name:"
- $Password = Read-Host "Password" -AsSecureString
- $AdminGroup = [ADSI]"WinNT://$Computer/Administrators,group"
- $CompObject = [ADSI]"WinNT://$Computer"
- $User = $CompObject.Create('User',$UserName)
- $Cred = New-Object -TypeName System.Management.Automation.PSCredential -
- ArgumentList $UserName, (ConvertTo-SecureString $Password -AsPlainText –
- Force)
- $User.SetPassword($Cred.GetNetworkCredential().Password)
- $User.SetInfo()
- $AdminGroup.Add($User.Path)
Add Comment
Please, Sign In to add comment