32 lines
551 B
PowerShell
32 lines
551 B
PowerShell
# load ActiveDirectory module
|
|
Try
|
|
{
|
|
Import-Module ActiveDirectory -ErrorAction Stop
|
|
}
|
|
Catch
|
|
{
|
|
Write-Warning $_
|
|
Break
|
|
}
|
|
|
|
function Unlock-Account
|
|
{
|
|
$username = Read-Host 'Please enter a user name'
|
|
Try
|
|
{
|
|
Unlock-ADAccount -Identity $username -ErrorAction Stop
|
|
Write-Host
|
|
Write-Host $username ' unlocked' -backgroundcolor green
|
|
Write-Host
|
|
}
|
|
Catch
|
|
{
|
|
Write-Warning $_
|
|
Read-Host 'Press a key to quit'
|
|
Break
|
|
}
|
|
Read-Host 'Press a key to quit'
|
|
}
|
|
|
|
Unlock-Account
|