-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAD_MassProxyAddress.ps1
28 lines (21 loc) · 1.48 KB
/
AD_MassProxyAddress.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
###############################################################################################################
# NOTE - Please make sure to read through the comments to see what additional actions are required #
# This script is used to change the proxyAddress attribute in Active Directory for several accounts at once #
# ALSO NOTE - THIS CAN ONLY BE RUN WHEN ON THE DOMAIN CONTROLLER - DOES NOT CONNECT TO O365 #
###############################################################################################################
#This imports the ActiveDirectory module to be used in the session
Import-Module ActiveDirectory
# This creates a variable called $users which contains all of the email addresses you add below
# NOTE - You will need to add the list of uers down below, following the syntax as shown. Extra space given to add more
$users = @(
)
# This command runs through each user in the $users variable and changes the SMTP proxyAddress to what is added below
foreach ($userPrincipalName in $users) {
$adUser = Get-ADUser -Filter "UserPrincipalName -eq '$userPrincipalName'" -Properties proxyAddresses
# NOTE - YOU NEED TO UPDATE THE VALUE OF "@newdomain.com" BELOW TO BE THE DOMAIN YOU ARE WANTING
$newProxyAddress = "SMTP:" + $adUser.samAccountName + "@newdomain.com"
Set-ADUser -Identity $adUser -Add @{proxyAddresses = $newProxyAddress}
}