DisableADAccountsMenu.ps1
19 Sep 2025Description
Purpose
Displays a menu to disable Active Directory user accounts.
Detailed Description
The DisableADAccountsMenu function displays a menu with options to disable specific Active Directory user accounts. It uses the PSMenu module to create the menu and calls the appropriate functions to disable the selected user account.
Usage
Example 1
DisableADAccountsMenu
Displays the menu to disable Active Directory user accounts.
Notes
This function requires the PSMenu module to be imported.
Script
#requires -Modules PSMenu
#requires -PSEdition Desktop
<#
.SYNOPSIS
Displays a menu to disable Active Directory user accounts.
.DESCRIPTION
The DisableADAccountsMenu function displays a menu with options to disable specific Active Directory user accounts.
It uses the PSMenu module to create the menu and calls the appropriate functions to disable the selected user account.
.PARAMETER None
.INPUTS
None
.OUTPUTS
None
.EXAMPLE
DisableADAccountsMenu
Displays the menu to disable Active Directory user accounts.
.NOTES
This function requires the PSMenu module to be imported.
.LINK
PSMenu module: https://github.com/gangstanthony/PSMenu
#>
function DisableADAccountsMenu {
# Import the PSMenu module
Import-Module PSMenu
# Define the actions
function Disable-JohnSmith {
Disable-ADAccount -Identity JohnSmith.admin
Write-Output "Account JohnSmith.admin has been disabled."
}
function Disable-JackDaniels {
Disable-ADAccount -Identity JackDaniels.admin
Write-Output "Account JackDaniels.admin has been disabled."
}
function Disable-GeoffGeoffries {
Disable-ADAccount -Identity GeoffGeoffries.admin
Write-Output "Account GeoffGeoffries.admin has been disabled."
}
# Create the menu items
$menuItems = @(
"Disable John Smith Account",
"Disable Jack Daniels Account",
"Disable Geoff Geoffries Account",
$(Get-MenuSeparator),
"Exit"
)
# Display the menu
$Menu = Show-Menu -MenuItems $menuItems -ReturnIndex -ItemFocusColor "Yellow"
# Use the correct comparison operator and check the value of $Menu
switch ($Menu) {
0 { Disable-JohnSmith }
1 { Disable-JackDaniels }
2 { Disable-GeoffGeoffries }
default { Write-Output "Nothing Selected" }
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.