#
Entra-UserExternal-Create.ps1
Purpose Dependencies Function Usage Inputs Variables Command Line Flags Outputs Notes
#
Purpose
Automates the creation of external (guest) users in Entra ID (Azure AD), supporting both single and bulk user creation. Handles sponsor resolution, expiry dates, and provides a summary for Service Desk tickets.
#
Dependencies
- PowerShell 7.0 or later (Install Guide)
- Microsoft Graph module (Microsoft Docs)
- Require-Pwsh7.ps1 (local script, must be accessible and dot-sourced)
#
Function
- Loads and validates required modules (installs if missing).
- Connects to Microsoft Graph with required permissions.
- Prompts for single or bulk user creation (CSV import).
- For each user:
- Resolves sponsor by display name (with interactive selection if ambiguous).
- Gathers/validates expiry date (defaults to 90 days if blank).
- Sends invite and sets user properties (job title, company, expiry, manager, etc.).
- Updates CSV and provides progress feedback in bulk mode.
- Provides a summary of actions for Service Desk ticketing and copies it to clipboard.
#
Usage
./Entra-UserExternal-Create.ps1
The script is interactive and supports both single and bulk user creation. All required information is prompted or read from CSV.
#
Inputs
- Interactive prompts for user details (single mode)
- CSV file for bulk user creation (fields: firstName, lastName, jobTitle, companyName, emailAddress, invitePurpose, sponsor, expiryDate)
#
Variables
$moduleNames
: Required modules$csvPath
: Path to CSV for bulk mode$sponsor
: Sponsor user object$expiryDate
: Expiry date for external user
#
Command Line Flags
None for standard use.
#
Outputs
- Creates external users and sends invites
- Sets user properties (job title, company, expiry, manager, etc.)
- Updates CSV with status in bulk mode
- Copies summary to clipboard and displays for Service Desk ticketing
#
Notes
- Requires PowerShell 7, Microsoft Graph module, and local Require-Pwsh7.ps1 script
- Script provides clear error messages and instructions for each step