Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <# Script: Menu.ps1 by Patrick Deno
- Purpose: To allow a user (Admin) to select and run any of a number of management/maintenance scripts, dealing with Active Directory, MS Exchange, or the general Network tasks, from a single interactive interface on my company's network.
- Last Updated: August 30th, 2018 #>
- <# --- Begin Pathing --- #>
- $ScriptRoot = "\\MyDataServer\Install\IT - Share\Helpful BATs & Scripts"
- <# --- Active Directory Path --- #>
- $pathADAudit = $ScriptRoot+ "\Active Directory\AD Auditing\"
- $pathADManagement = $ScriptRoot+ "\Active Directory\AD Management\"
- $pathADUser = $ScriptRoot+ "\Active Directory\AD User Management\"
- <# --- Exchange Path --- #>
- $pathExAudit = $ScriptRoot+ "\Exchange Scripts\Exchange Auditing\"
- $pathExManagment = $ScriptRoot+ "\Exchange Scripts\Exchange Management\"
- $pathExUser = $ScriptRoot+ "\Exchange Scripts\User Account Management\"
- <# --- Network Path --- #>
- $pathNetwork = $ScriptRoot+ "\Network\"
- <# --- End Pathing --- #>
- <# --- Variable Decision Engine --- #>
- $LoopMain = "0"
- Function ExitMessage {
- CLS
- Write-Host "No script chosen.
- Exited.
- "
- }
- While ($LoopMain -ne "1") {
- <# --- (Re)initializing variables --- #>
- $Exit = "0"
- $LoopAD = "0"
- $LoopEX = "0"
- $LoopNW = "0"
- $MainChoice = $NULL
- $ADSubMainChoice = $NULL
- $ADSub1stChoice = $NULL
- $ADSub2ndChoice = $NULL
- $ADSub3rdChoice = $NULL
- $EXSub1stChoice = $NULL
- $EXSub2ndChoice = $NULL
- $EXSub3rdChoice = $NULL
- $NWSubMainChoice = $NULL
- $ScriptArray = $NULL
- $ScriptChoice = $NULL
- <# --- Main Menu Loop --- #>
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor White
- Write-Host "** Please choose a script type **" -ForegroundColor White
- Write-Host "** **" -ForegroundColor White
- Write-Host "** Please choose one **" -ForegroundColor White
- Write-Host "** **" -ForegroundColor White
- Write-Host "** (1) Active Directory **" -ForegroundColor White
- Write-Host "** (2) Exchange **" -ForegroundColor White
- Write-Host "** (3) Network **" -ForegroundColor White
- Write-Host "** (4) Exit **" -ForegroundColor White
- Write-Host "** **" -ForegroundColor White
- Write-Host "********************************************" -ForegroundColor White
- $MainChoice = Read-Host "Main menu choice?"
- } while (1..4 -notcontains $MainChoice)
- <# --- Main Menu Choice Loop --- #>
- <# --- Active Directory Main Menu --- #>
- If ($MainChoice -eq "1") {
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Cyan
- Write-Host "** Please choose Active Directory Group **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** Please choose one **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** (1) AD Auditing **" -ForegroundColor Cyan
- Write-Host "** (2) AD Management **" -ForegroundColor Cyan
- Write-Host "** (3) AD User management **" -ForegroundColor Cyan
- Write-Host "** (4) Back **" -ForegroundColor Cyan
- Write-Host "** (5) Exit **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "********************************************" -ForegroundColor Cyan
- $ADSubMainChoice = Read-Host "AD menu choice?"
- } while (1..5 -notcontains $ADSubMainChoice)
- <# --- Active Directory Choice Loop --- #>
- While ($LoopAD -ne "1") {
- If ($ADSubMainChoice -eq "1") {
- $PathChoice = $pathADAudit
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** Active Directory Auditing **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** Please choose one **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** (1) Export All User Memberships **" -ForegroundColor Cyan
- Write-Host "** (2) Export All Computers **" -ForegroundColor Cyan
- Write-Host "** (3) Export All Disabled Users **" -ForegroundColor Cyan
- Write-Host "** (4) Export All Users In Group **" -ForegroundColor Cyan
- Write-Host "** (5) Export Inactive Users (90 Days) **" -ForegroundColor Cyan
- Write-Host "** (6) Export All Computers **" -ForegroundColor Cyan
- Write-Host "** (7) Back **" -ForegroundColor Cyan
- Write-Host "** (8) Exit **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "********************************************" -ForegroundColor Cyan
- $ADSub1stChoice = Read-Host "AD Auditing Script?"
- } while (1..8 -notcontains $ADSub1stChoice)
- If ($ADSub1stChoice -eq "7") {
- $LoopAD = "1"
- Break
- } ElseIf ($ADSub1stChoice -eq "8") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- $ScriptArray = "AD-AllUserMemberships.ps1","AD-DisabledCompsAudit.ps1","AD-DisabledUsersAudit.ps1","AD-GetAllUsersInGroup.ps1","AD-InActiveUsers-90DaysAudit.ps1","AD-ListAllComputers.ps1"
- $ScriptChoice = $ScriptArray[$ADSub1stChoice -1]
- $LoopAD = "1"
- $LoopMain = "1"
- Break
- }
- } ElseIf ($ADSubMainChoice -eq "2") {
- $PathChoice = $pathADManagement
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** Active Directory Management **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** Please choose one **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** (1) Force ADs To Replicate **" -ForegroundColor Cyan
- Write-Host "** (2) Back **" -ForegroundColor Cyan
- Write-Host "** (3) Exit **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "********************************************" -ForegroundColor Cyan
- $ADSub2ndChoice = Read-Host "AD Management Script?"
- } while (1..3 -notcontains $ADSub2ndChoice)
- IF ($ADSub2ndChoice -eq "2") {
- $LoopAD = "1"
- Break
- } ElseIf ($ADSub2ndChoice -eq "3") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- $ScriptChoice = "ForceADsToReplicate.ps1"
- $LoopAD = "1"
- $LoopMain = "1"
- Break
- }
- } ElseIf ($ADSubMainChoice -eq "3") {
- $PathChoice = $pathADUser
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** Active Directory User Management **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** Please choose one **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "** (1) Onboard an incoming user **" -ForegroundColor Cyan
- Write-Host "** (2) Offboard a departing user **" -ForegroundColor Cyan
- Write-Host "** (3) Copy Permissions from user A to B **" -ForegroundColor Cyan
- Write-Host "** (4) Disable a user account **" -ForegroundColor Cyan
- Write-Host "** (5) Enable a user account **" -ForegroundColor Cyan
- Write-Host "** (6) Reset a user password **" -ForegroundColor Cyan
- Write-Host "** (7) Back **" -ForegroundColor Cyan
- Write-Host "** (8) Exit **" -ForegroundColor Cyan
- Write-Host "** **" -ForegroundColor Cyan
- Write-Host "********************************************" -ForegroundColor Cyan
- $ADSub3rdChoice = Read-Host "AD User Management Script?"
- } while (1..8 -notcontains $ADSub3rdChoice)
- IF ($ADSub3rdChoice -eq "7") {
- $LoopAD = "1"
- Break
- } ElseIf ($ADSub3rdChoice -eq "8") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- $ScriptArray = "Onboarding and Offboarding\AD-OnboardincomingUser++.ps1","Onboarding and Offboarding\AD-OffboardDepartingUser++.ps1","AD-CopyPermissionsFromAtoB.ps1","AD-DisableUserAccount.ps1","AD-EnableUserAccount.ps1","AD-ResetUserPassword.ps1"
- $ScriptChoice = $ScriptArray[$ADSub3rdChoice -1]
- $LoopAD = "1"
- $LoopMain = "1"
- Break
- }
- } ElseIf ($ADSubMainChoice -eq "4") {
- $LoopAD = "1"
- Break
- } Else {
- ExitMessage
- $LoopMain = "1"
- Break Script
- }
- }
- <# --- Exchange Main Menu Loop --- #>
- } ElseIf ($MainChoice -eq "2") {
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Yellow
- Write-Host "** Please choose Exchange Group **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** Please choose one **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** (1) EX Auditing **" -ForegroundColor Yellow
- Write-Host "** (2) EX Management **" -ForegroundColor Yellow
- Write-Host "** (3) EX User management **" -ForegroundColor Yellow
- Write-Host "** (4) Back **" -ForegroundColor Yellow
- Write-Host "** (5) Exit **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "********************************************" -ForegroundColor Yellow
- $EXSubMainChoice = Read-Host "Exchange menu choice?"
- } while (1..5 -notcontains $EXSubMainChoice)
- <# --- Exchange Menu Choice Loop --- #>
- While ($LoopEX -ne "1") {
- If ($EXSubMainChoice -eq "1") {
- $PathChoice = $pathExAudit
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** Exchange Auditing **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** Please choose one **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** (1) Disable Exchange accounts of **" -ForegroundColor Yellow
- Write-Host "** disabled AD users **" -ForegroundColor Yellow
- Write-Host "** (2) Hide disabled users from global **" -ForegroundColor Yellow
- Write-Host "** address list **" -ForegroundColor Yellow
- Write-Host "** (3) Export disconnected mailboxes **" -ForegroundColor Yellow
- Write-Host "** (4) Top 10 biggest mailboxes **" -ForegroundColor Yellow
- Write-Host "** (5) Track an email send failure **" -ForegroundColor Yellow
- Write-Host "** (6) Back **" -ForegroundColor Yellow
- Write-Host "** (7) Exit **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "********************************************" -ForegroundColor Yellow
- $EXSub1stChoice = Read-Host "EX Auditing Script?"
- } while (1..7 -notcontains $EXSub1stChoice)
- IF ($EXSub1stChoice -eq "6") {
- $LoopEX = "1"
- Break
- } ElseIf ($EXSub1stChoice -eq "7") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- $ScriptArray = "DisableEmailAccountsInAD-DisabledUsers.ps1","HideDisabledUsersFromGlobalAddressList.ps1","ExportDisconnectedMailBoxes.ps1","Top10Mailboxes.ps1","TrackEmailFailures.ps1"
- $ScriptChoice = $ScriptArray[$EXSub1stChoice -1]
- $LoopEX = "1"
- $LoopMain = "1"
- Break
- }
- } ElseIf ($ExSubMainChoice -eq "2") {
- $PathChoice = $pathExManagment
- do {
- CLS
- Write-Host "**********************************************" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** Exchange Management **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** Please choose one **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** (1) Add address to blocked senders **" -ForegroundColor Yellow
- Write-Host "** (2) Add address to bypass senders **" -ForegroundColor Yellow
- Write-Host "** (3) Domain to blocked Domains & Subs **" -ForegroundColor Yellow
- Write-Host "** (4) Add spam domains to block list **" -ForegroundColor Yellow
- Write-Host "** (5) Remove address from bypass senders **" -ForegroundColor Yellow
- Write-Host "** (6) Remove address from blocked senders **" -ForegroundColor Yellow
- Write-Host "** (7) Remove domain from block list **" -ForegroundColor Yellow
- Write-Host "** (8) Export blocked domains (c:\temp\) **" -ForegroundColor Yellow
- Write-Host "** (9) Export blocked senders (c:\temp\) **" -ForegroundColor Yellow
- Write-Host "** (10) Export bypass senders (c:\temp\) **" -ForegroundColor Yellow
- Write-Host "** (11) Import bad domains (c:\temp\) **" -ForegroundColor Yellow
- Write-Host "** (12) Back **" -ForegroundColor Yellow
- Write-Host "** (13) Exit **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "**********************************************" -ForegroundColor Yellow
- $EXSub2ndChoice = Read-Host "EX Management Script?"
- } while (1..13 -notcontains $EXSub2ndChoice)
- IF ($EXSub2ndChoice -eq "12") {
- $LoopEX = "1"
- Break
- } ElseIf ($EXSub2ndChoice -eq "13") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- $ScriptArray = "Black & White Lists\AddAddressToBlockedSendersList.ps1","Black & White Lists\AddAddressToBypassedSendersList.ps1","Black & White Lists\AddSpamDomainsToBlockList.ps1","Black & White Lists\RemoveAddressFromBypassedSendersList.ps1","Black & White Lists\RemoveSenderFromBlockedSendersList.ps1","Black & White Lists\RemoveSpamDomainsFromBlockList.ps1","Black & White Lists\Import & Export\ExportBlockedDomainsList.ps1","Black & White Lists\Import & Export\ExportBlockedSendersList.ps1","Black & White Lists\Import & Export\ExportBypassedSendersList.ps1","Black & White Lists\Import & Export\ImportBadDomainsList.ps1"
- $ScriptChoice = $ScriptArray[$EXSub2ndChoice -1]
- $LoopEX = "1"
- $LoopMain = "1"
- Break
- }
- } ElseIf ($ExSubMainChoice -eq "3") {
- $PathChoice = $pathExUser
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** Exchange User Account Management **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** Please choose one **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "** (1) Delete disabled user by GUID **" -ForegroundColor Yellow
- Write-Host "** (2) Delete user folder contents **" -ForegroundColor Yellow
- Write-Host "** (3) Discovery Search **" -ForegroundColor Yellow
- Write-Host "** (4) Set Out-Of-Office reply **" -ForegroundColor Yellow
- Write-Host "** (5) Reconnect a disabled mailbox **" -ForegroundColor Yellow
- Write-Host "** (6) Reset a user's Role Ass. Policy **" -ForegroundColor Yellow
- Write-Host "** (7) Set a calendar reminder **" -ForegroundColor Yellow
- Write-Host "** (8) Back **" -ForegroundColor Yellow
- Write-Host "** (9) Exit **" -ForegroundColor Yellow
- Write-Host "** **" -ForegroundColor Yellow
- Write-Host "********************************************" -ForegroundColor Yellow
- $EXSub3rdChoice = Read-Host "EX User Management Script?"
- } while (1..9 -notcontains $EXSub3rdChoice)
- IF ($EXSub3rdChoice -eq "8") {
- $LoopEX = "1"
- Break
- } ElseIf ($EXSub3rdChoice -eq "9") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- $ScriptArray = "DeleteDisabledUserByGUID.ps1","DeleteFolderContents.ps1","DiscoverySearchSimplified.ps1","OutOfOfficeReplyToBothExternalAndInternal-GUI.ps1","ReconnectDisabledMailbox.ps1","ResetUser'sRoleAssignmentPolicyInExchange.ps1","SetCalendarReminder.ps1"
- $ScriptChoice = $ScriptArray[$EXSub3rdChoice -1]
- $LoopEX = "1"
- $LoopMain = "1"
- Break
- }
- } ElseIf ($ExSubMainChoice -eq "4") {
- $LoopMain -ne "1"
- Break
- } Else {
- ExitMessage
- $LoopMain = "1"
- Break Script
- }
- }
- } ElseIf ($MainChoice -eq "3") {
- <# --- Network Main Menu Loop --- #>
- While ($LoopNW -ne "1") {
- $PathChoice = $pathNetwork
- do {
- CLS
- Write-Host "********************************************" -ForegroundColor Green
- Write-Host "** **" -ForegroundColor Green
- Write-Host "** Network User Management **" -ForegroundColor Green
- Write-Host "** **" -ForegroundColor Green
- Write-Host "** Please choose one **" -ForegroundColor Green
- Write-Host "** **" -ForegroundColor Green
- Write-Host "** (1) Find computer user is logged into **" -ForegroundColor Green
- Write-Host "** (2) Log off -ALL- remote users **" -ForegroundColor Green
- Write-Host "** (3) Log off remote user **" -ForegroundColor Green
- Write-Host "** (4) Log off remote user 2 **" -ForegroundColor Green
- Write-Host "** (5) Enable winrm on remote computer **" -ForegroundColor Green
- Write-Host "** (6) Show who and when last logged **" -ForegroundColor Green
- Write-Host "** on to remote computer **" -ForegroundColor Green
- Write-Host "** (7) Back **" -ForegroundColor Green
- Write-Host "** (8) Exit **" -ForegroundColor Green
- Write-Host "** **" -ForegroundColor Green
- Write-Host "********************************************" -ForegroundColor Green
- $NWSubMainChoice = Read-Host "Network menu choice?"
- } while (1..8 -notcontains $NWSubMainChoice)
- IF ($NWSubMainChoice -eq "7") {
- $LoopNW = "1"
- Break
- } ElseIf ($NWSubMainChoice -eq "8") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- $ScriptArray = "FindComputerUserLoggedInto.ps1","LogOffAllRemoteUsers.ps1","LogoffRemoteUser.ps1","LogoffRemoteUser2.ps1","remotely_enable_winrm.ps1","WhoLoggedOn.ps1"
- $ScriptChoice = $ScriptArray[$NWSubMainChoice -1]
- $LoopNW = "1"
- $LoopMain = "1"
- Break
- }
- }
- } ElseIf ($MainChoice -eq "4") {
- ExitMessage
- $LoopMain = "1"
- Break Script
- } Else {
- Break
- }
- }
- $path = $PathChoice + $ScriptChoice
- cls
- $params = "menu"
- &$path $params
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement