Lo script PowerShell più in basso può essere utilizzato per reimpostare automaticamente le password a intervalli regolari. ADSelfService Plus offre inoltre un'opzione che può essere utilizzata per reimpostare automaticamente le password degli utenti del dominio alla loro scadenza. Quando questa opzione è abilitata, uno strumento di pianificazione viene eseguito a intervalli regolari per cercare gli account utente con password scadute e reimpostare automaticamente le password. Le nuove password vengono poi inviate tramite e-mail agli utenti. Questo è un confronto della reimpostazione automatica delle password con PowerShell e ADSelfService Plus:
Param (
[Parameter(Mandatory=$True)]
[String]$InputFile
)
Function MakeRandomPass {
Param (
[Int]$PLength
)
If ($PLength -LT 4) {Return $Null}
$Numbers = $Null
For ($A=48;$A -LE 57;$A++) {$Numbers+=,[Char][Byte]$A}
$UpCase = $Null
For ($A=65;$A -LE 90;$A++) {$UpCase+=,[Char][Byte]$A}
$LowCase = $Null
For ($A=97;$A -LE 122;$A++) {$LowCase+=,[Char][Byte]$A}
$SpChar = $Null
For ($A=33;$A -LE 47;$A++) {$SpChar+=,[Char][Byte]$A}
For ($A=58;$A -LE 64;$A++) {$SpChar+=,[Char][Byte]$A}
For ($A=123;$A -LE 126;$A++) {$SpChar+=,[Char][Byte]$A}
$Buffer = @()
For ($A=1;$A -LE $PLength;$A++) {$Buffer+=0}
While ($True) {
$NumChar = (Get-Random -Minimum 0 -Maximum $PLength)
If ($Buffer[$NumChar] -EQ 0) {$Buffer[$NumChar] = 1; break}
}
While ($True) {
$NumChar = (Get-Random -Minimum 0 -Maximum $PLength)
If ($Buffer[$NumChar] -EQ 0) {$Buffer[$NumChar] = 2; break}
}
While ($True) {
$NumChar = (Get-Random -Minimum 0 -Maximum $PLength)
If ($Buffer[$NumChar] -EQ 0) {$Buffer[$NumChar] = 3; break}
}
While ($True) {
$NumChar = (Get-Random -Minimum 0 -Maximum $PLength)
If ($Buffer[$NumChar] -EQ 0) {$Buffer[$NumChar] = 4; break}
}
$ThisPassword = $Null
ForEach ($CharType In $Buffer) {
If ($CharType -EQ 0) {
$CharType = ((1,2,3,4) | Get-Random)
}
Switch ($CharType) {
1 {$ThisPassword+=($Numbers | Get-Random)}
2 {$ThisPassword+=($UpCase | Get-Random)}
3 {$ThisPassword+=($LowCase | Get-Random)}
4 {$ThisPassword+=($SpChar | Get-Random)}
}
}
Return $ThisPassword
}
$ErrorActionPreference = "SilentlyContinue"
$T = Get-Date
If ($Error) {$Error.Clear()}
Write-Host "`n"
Write-Host "Working. Please wait"
Write-Host "`n"
$RepFile = $T -Replace " ", $Null
$RepFile = $RepFile -Replace ":", $Null
$RepFile = $RepFile -Replace "/", $Null
$RepFile = $RepFile -Replace "-", $Null
If (Test-Path "Report_$RepFile.txt") {
Remove-Item "Report_$RepFile.txt"
}
New-Item -Path "Report_$RepFile.txt" -Type File -Force -Value "REPORT: Reset Local User Account Password On Multiple Computers" | Out-Null
Add-Content "Report_$RepFile.txt" "`n"
Add-Content "Report_$RepFile.txt" "`n"
Add-Content "Report_$RepFile.txt" "Report Created On $T"
Add-Content "Report_$RepFile.txt"
Add-Content "Report_$RepFile.txt" "`n"
Import-CSV -Path $InputFile | ForEach-Object {
Try {
$ThisMachine = $_.ComputerName
$ThisAccount = $_.LocalAccountLoginID
If (!([string]::IsNullOrEmpty($ThisMachine)) -AND !([string]::IsNullOrEmpty($ThisAccount))) {
Write-Host "`tAttempting to reset the local account password in computer: $ThisMachine" -ForeGroundColor "Yellow"
$PassToSet = MakeRandomPass 20
$ThisUser = [ADSI]"WinNT://$ThisMachine/$ThisAccount, User"
$ThisUser.SetPassword($PassToSet)
$ThisUser.SetInfo()
If (!$Error) {
Add-Content "Report_$RepFile.txt" "$ThisMachine `t`t -- $ThisAccount `t`t -- $PassToSet `t`t --success: Password Has Been Reset/Changed."
}
}
}
Catch {
[System.Exception] | Out-Null
If ($Error) {
Add-Content "Report_$RepFile.txt" "$ThisMachine `t`t -- $ThisAccount `t`t -- Password Reset has failed. An Error Has Occurred."
Add-Content "Report_$RepFile.txt" $Error
$Error.Clear()
}
}
}
Write-Host "`n"
Write-Host "Task Completed. Check Report File: Report_$RepFile.txt"
Notepad "Report_$RepFile.txt"
Write-Host "`n"
Con ADSelfService Plus, la reimpostazione automatica delle password può essere abilitata con pochi clic e inserendo un numero ridotto di informazioni. In PowerShell, è necessario creare, effettuare il debug ed eseguire gli script.
Durante la creazione di un criterio in ADSelfService, gli amministratori possono selezionare i gruppi, domini o unità organizzative i cui utenti avranno la reimpostazione automatica delle password alla scadenza. L'utilizzo di PowerShell per la reimpostazione automatica della password per utenti specifici richiede la creazione e il mantenimento di uno script lungo
Lo strumento di applicazione dei criteri delle password di ADSelfService Plus consente agli amministratori di creare e applicare criteri personalizzati relativi alle password per impedire la creazione di password vulnerabili. Le password generate automaticamente possono essere scegliere per soddisfare questo criterio personalizzato relativo alle password.
La funzionalità di sincronizzazione delle password di ADSelfService Plus sincronizza automaticamente le nuove password con gli account degli utenti in applicazioni aziendali come G Suite e Salesforce.
Acquisisce tutte le operazioni di reimpostazione delle password nei report che possono essere facilmente generati con un singolo clic ed esportati in vari formati come HTML, CSV, PDF e XLS.
Agli amministratori viene inviato periodicamente un report che contiene i dettagli di tutte le operazioni di reimpostazione delle password.
Reimposta automaticamente le password degli utenti di Active Directory.