#
User-Departure.ps1
Purpose Dependencies Function Usage Inputs Variables Command Line Flags Outputs Notes
#
Purpose
Automates the departure/offboarding of Active Directory user accounts with a graphical user interface (GUI). Collects required information, disables the account, moves it to the correct OU, removes user from distribution lists and key groups, updates Exchange mailbox, and triggers a delta sync for Azure AD. Designed for both single and bulk user processing.
#
Dependencies
- Active Directory module (Microsoft Docs)
- Exchange Online Management module (Microsoft Docs)
- Windows Forms (part of .NET, used for GUI)
#
Function
- Loads required modules and presents a Windows Forms GUI for user input (full name or logon name).
- Validates user existence in AD.
- Resets the user's password to a default value.
- Disables the AD account.
- Hides the mailbox from the GAL and converts it to a shared mailbox.
- Moves the user account to the "Disabled Accounts" OU.
- Removes the user from distribution lists, E3/E1 license groups, signature, and KnowBe4 groups; re-adds to e1_office if needed.
- Triggers a delta sync for Azure AD.
- Provides user feedback via custom pop-up messages and focuses the form for rapid repeated use.
#
Usage
./User-Departure.ps1
The script is fully interactive and uses a GUI. No command-line parameters are required for standard use.
#
Inputs
- User input via GUI: Full Name or Logon Name
#
Variables
$textBoxFullName
: GUI field for user input$logonname
: Derived logon name from full name$groups
: List of groups to remove the user from
#
Command Line Flags
None for standard use.
#
Outputs
- Disables the user account
- Moves account to Disabled Accounts OU
- Converts mailbox to shared and hides from GAL
- Removes from key groups and distribution lists
- Triggers Azure AD delta sync
- Provides pop-up feedback for each step
#
Notes
- Requires the Active Directory and Exchange Online Management modules
- GUI-based; not suitable for headless environments
- Manual check of mailbox conversion is recommended after script completion