From Evernote: |
Reset all local admin ID's on all servers in hosts file |
$Server=(Read-Host "Server")
$UserName=(Read-Host "UserName")
$Password = Read-Host -assecurestring "Please enter your password"
$PasswordConfirm = Read-Host -assecurestring "Confirm password"
$IsPasswordGood = [string]::Compare($Password, $PasswordConfirm, $IsPasswordGood)
$tempCredential = New-Object System.Management.Automation.PsCredential "None",$password
If ($IsPasswordGood -eq 0)
{
$Password = $tempCredential.GetNetworkCredential().Password
$LocalUser =[adsi]("WinNT://$Server/$Username, user")
$LocalUser.psbase.invoke("SetPassword", $Password)
}
Else
{
Write-Host "** Passwords don't match **"
}
$UserName=(Read-Host "UserName")
$Password = Read-Host -assecurestring "Please enter your password"
$PasswordConfirm = Read-Host -assecurestring "Confirm password"
$IsPasswordGood = [string]::Compare($Password, $PasswordConfirm, $IsPasswordGood)
$tempCredential = New-Object System.Management.Automation.PsCredential "None",$password
If ($IsPasswordGood -eq 0)
{
$Password = $tempCredential.GetNetworkCredential().Password
$LocalUser =[adsi]("WinNT://$Server/$Username, user")
$LocalUser.psbase.invoke("SetPassword", $Password)
}
Else
{
Write-Host "** Passwords don't match **"
}
No comments:
Post a Comment