User Tools

Site Tools


change_domainpassword_via_powershell

Hier ein Script um einem Useraccount ein neues Passwort in der Domäne zu setzen

changeuserpassword.ps1
<
Write-Host 
Write-Host "Set new Useraccount Password" -foreground "yellow"
Write-Host
 
$cmdlet = "ActiveDirectory" 
if ( (get-command -Name $cmdlet -ErrorAction SilentlyContinue) -eq $null ) {Import-module ActiveDirectory} 
 
$ExecUser = ([Environment]::UserName) 
 
function Get-ScriptDirectory
{
$Invocation = (Get-Variable MyInvocation -Scope 1).Value
Split-Path $Invocation.MyCommand.Path
}
$ScriptPath = Get-ScriptDirectory
 
$User = Read-Host -Prompt "Provide User Name"
 
$Password = (Read-Host -Prompt "Provide New Password" -AsSecureString) 
 
Write-Host "Set Change Password at Next Logon?"
 
Write-Host "Press Y for Yes" -foreground "yellow" 
Write-Host "Press N for No" -foreground "yellow"
write-host
 
$auswahl = read-host -Prompt "Set Change Password at Next Logon?"
 
 
if ($auswahl -eq "Y") {Set-ADAccountPassword -Identity $User -NewPassword $Password | Set-ADuser -ChangePasswordAtLogon $True}
else {Set-ADAccountPassword -Identity $User -NewPassword $Password}
 
get-aduser -identity $User -properties passwordlastset, passwordneverexpires | sort name | ft Name, passwordlastset, Passwordneverexpires
write-host
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
change_domainpassword_via_powershell.txt · Last modified: 2019/02/11 17:17 by 192.168.1.1