#Leave any comments with the # sign
#Install Quest Active Directory CMDLets
Write-Host “Installing Quest Active Directory Tools. Please wait…”
Add-PSSnapin Quest.ActiveRoles.ADManagement
Write-Host “Installing Exchange Management Tools. Please wait…”
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin
#Next line is to change directory to your scripts folder. Recommend C:\Scripts
CD C:\Scripts
#Next line is to run your Admin script
.\Admin.ps1
#This script unlocks a users account with the credentials of the user logged in
$name = Read-Host "Account Username or last name"
if ($Name.contains(".")) #Most user accounts are first.last
{
Unlock-QADUser "DOMAIN\$name"
}
else
{
$LastNameMatches = get-qaduser $Name
if ($LastNameMatches -eq $null){
Write-Host "No Matches Found!"
$Pause = Read-Host "Press Enter to Continue..."
.\admin
}
else
{
if ($LastNameMatches.count -gt "1"){
Write-Host "Matches found:"
$counter = [int]0
foreach ($Name in $LastNameMatches){
$Description = $name.description
$UnlockStatus = $Name.accountislockedout
Write-Host "$counter : $Name - $Description - Locked Out: $UnlockStatus"
$counter++
} #End FOREACH
$Selection = Read-Host "Select a user by number only"
$user = $lastnamematches[$selection]
unlock-qaduser $user
Write-Host "Unlocked $User"
}
else
{
unlock-qaduser $LastNameMatches
Write-Host "Unlocked $LastNameMatches"
}#end if
} #end if
}#end if
$Pause = Read-Host "Press Enter to Continue..."
.\admin
Clear-Host
Do #Ensures user has input a proper value
{
"Welcome to the Account Administration Script"
Write-Host "Pick from the following options" -foreground "yellow"
""
"1. Create New Account"
"2. Unlock Account"
"3. Reset Account Password"
"4. Enable/Disable Account"
"5. Account Status"
""
[int]$strChoice = Read-Host "Enter Choice(1-5)"
if ($strChoice -eq ""){$strChoice = 1}
} #end do for Description
While (($strChoice -lt 1) -or ($strChoice -gt 5))#-gt means Greater Than as opposed to '>' symbol
""
""
#Depending on what user inputs, chooses the proper assignment of variable
Switch ($strChoice)
{
1 {.\accounts.ps1}
2 {.\Unlock.ps1}
3 {.\ResetPW.ps1}
4 {.\EnableAccount.ps1}
5 {.\StatusAccount.ps1}
Default {.\Accounts.ps1}
} #end Switch Statement
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (4)
Commented:
Author
Commented:Also, if you have indexing turned on, you can type in Powershell in your start menu search bar, and it should bring it up.
This article is just one step past the article listed above:
https://www.experts-exchange.com/OS/Microsoft_Operating_Systems/Server/Windows_Server_2008/A_3296-The-Absolute-Beginner's-Guide-to-Powershell.html
If you're just starting out, you should definitely read that article first.
Thanks for reading this article!
Dale Harris
Commented:
Author
Commented:Thanks for the comments. I do hope you achieve your Master status quickly and you should absolutely share with us what you've cooked up for your environment!
-Dale