IDEE
← Guide to create aliases for multiple users using Powershell

πŸ“§ AddAlias.ps1 Setup Guide

🎯 What This Script Does

This script finds all users in a specified OU and gives them a new email alias. This new alias (e.g., user@authn.domain.com) can be used to sign in to their main account (user@domain.com).

πŸ› οΈ Step 1: Prepare Your Environment

  1. Create an Organizational Unit (OU) in Active Directory.

    • Move all users who need aliases into this OU.

    • Example OU: OU=AuthN_Users,DC=domain,DC=com

✏️ Step 2: Customize the Script

  1. Right-click the AddAlias.ps1 file and choose Edit (or open with Notepad/VS Code).

  2. Update Line 1:

    • Change the OU path to match your environment.

    • # Replace this:
      $Users = Get-ADUser -Filter * -SearchBase "OU=TestUsers,DC=domain,DC=com"

    • # With your OU path (Example):
      $Users = Get-ADUser -Filter * -SearchBase "OU=AuthN Users,DC=contoso,DC=com"

  3. Update Line 4:

    • Change the alias domain to match yours.

    • # Replace this:
      "smtp:$($user.samaccountname)@new.domain.com"

    • # With your alias domain (Example):
      "smtp:$($user.samaccountname)@authn.domain.com"

  4. Save the file.