30 lines
513 B
PowerShell
30 lines
513 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 $username ' unlocked' -backgroundcolor green
|
||
|
}
|
||
|
Catch
|
||
|
{
|
||
|
Write-Warning $_
|
||
|
Read-Host 'Press a key to quit'
|
||
|
Break
|
||
|
}
|
||
|
Read-Host 'Press a key to quit'
|
||
|
}
|
||
|
|
||
|
Unlock-Account
|