← script library

Streamlined User Onboarding with PowerShell

Users & AccountsDecember 23, 2024

Welcome to our new section dedicated to sharing useful PowerShell scripts that can enhance your workflow. One of the most crucial aspects of IT management is user onboarding, and this script simplifies the process for Microsoft Entra ID. With just a few commands, you can automate the creation of user accounts and assign appropriate roles, ensuring that your team members have access to the tools they need from day one. Here is a sample PowerShell script for user onboarding:

powershell
# Import the required module
Import-Module AzureAD
# Define user details
$userEmail = "[email protected]"
$displayName = "New User"
$password = "P@ssw0rd!"
# Create the user
New-AzureADUser -DisplayName $displayName -UserPrincipalName $userEmail -MailNickName "newuser" -AccountEnabled $true -PasswordProfile @{ForceChangePasswordNextLogin=$true; Password=$password}
# Assign a role
$user = Get-AzureADUser -ObjectId $userEmail
Add-AzureADDirectoryRoleMember -ObjectId "your-role-object-id" -RefObjectId $user.ObjectId
Write-Host "User onboarding for $displayName completed successfully."

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.