# 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

# Function

  1. Loads required modules and presents a Windows Forms GUI for user input (full name or logon name).
  2. Validates user existence in AD.
  3. Resets the user's password to a default value.
  4. Disables the AD account.
  5. Hides the mailbox from the GAL and converts it to a shared mailbox.
  6. Moves the user account to the "Disabled Accounts" OU.
  7. Removes the user from distribution lists, E3/E1 license groups, signature, and KnowBe4 groups; re-adds to e1_office if needed.
  8. Triggers a delta sync for Azure AD.
  9. 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