Functions/Public/Unlock-LockedOutADUsers.ps1
<#
.SYNOPSIS This function performs an unlock of users in ActiveDirectory who are currently locked out. .DESCRIPTION This function is a simple wrapper for Unlock-ADAccount. .OUTPUTS None This function does not produce output except for write-output data .EXAMPLE PS>Unlock-LockedOutADUsers -SAMAccountName matthewjd Unlocking: matthewjd Description ----------- This will unlock the AD Account for user 'matthewjd'. .EXAMPLE PS>Get-LockedOutADUsers | Unlock-LockedOutADUsers Unlocking: User1 Unlocking: User2 Description ----------- This gets a list of all current locked out users from Get-LockedOutADUsers and forwards each user to Unlock-LockedOutADUsers, which effectively unlocked all currently locked AD Users A short-handed command for this using aliases: PS> glo | ul .NOTES Author: Matthew J. DeGarmo GitHub: https://github.com/matthewjdegarmo #> function Unlock-LockedOutADUsers() { [CmdletBinding()] param ( [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('Username')] [string[]]$SAMAccountName ) begin {} process { try { foreach ($Username in $SAMAccountName) { Write-Output "Unlocking: $Username" Unlock-ADAccount -Identity $Username -ErrorAction Stop } } catch { Write-Error "$($_.Exception.Message)" } } } # SIG # Begin signature block # MIIPcgYJKoZIhvcNAQcCoIIPYzCCD18CAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB # gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR # AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQULk94naW5kYQyYeS6Zid/FJxD # Ke2gggzlMIIGXzCCBUegAwIBAgIKFf/aSAACAACzwTANBgkqhkiG9w0BAQsFADBI # MRMwEQYKCZImiZPyLGQBGRYDY29tMRcwFQYKCZImiZPyLGQBGRYHbnBwZG5ldDEY # MBYGA1UEAxMPTlBQRElzc3VpbmdDQTA0MB4XDTE4MTAwNjAxMTkwMVoXDTIwMTAw # NTAxMTkwMVowJTEjMCEGA1UEAwwaRGVHYXJtbywgTWF0dGhldyBKLiBbRGFzaF0w # ggEiMA0GCSqGSIb3DQ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GCgmSJomT8ixkARkW # B25wcGRuZXQxGDAWBgNVBAMTD05QUERJc3N1aW5nQ0EwNAIKFf/aSAACAACzwTAJ # BgUrDgMCGgUAoHgwGAYKKwYBBAGCNwIBDDEKMAigAoAAoQKAADAZBgkqhkiG9w0B # CQMxDAYKKwYBBAGCNwIBBDAcBgorBgEEAYI3AgELMQ4wDAYKKwYBBAGCNwIBFTAj # BgkqhkiG9w0BCQQxFgQUFuNCldnXy36BHyqqknSnSwJGtLAwDQYJKoZIhvcNAQEB # BQAEggEAvxyC1niVhSJdbfVe2Rx6UA/NC57N5Vqbx19ei1PdmjVxSLbD2/2DoYLo # 1ZrVkwB6CkECyQniMhl3eE1uIfYLytZ+ABOck/AtbddlTR0sXWRhEa4UZJP8sLgE # slkbxn2SuF9jsieY7TxzkD/FIqGIwl6W0Rq6DLW9jL6h7mlwJ9t+P231eyIhsqSK # sy33OBDYDbE9H0ipFNiSRcO4BiAZA+7+o7ZJg6Xa28JkAzx2sLaUERmv8U8XdLYU # +YNSC5wHImSxYXpjur27QYgcxeGUkrtQ07ymGci7MTQzlQpe6PARKGqy0+on740P # rWDfJjC6eFwPJFQk0A+BEzCqwuK0jw== # SIG # End signature block |