Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Would like to automate this Powershell command that sets the UPN of all mail enabled users

$
0
0

I have command that changes the UPN of all mailbox users

Get-ADUser -Filter * -properties homemdb | where {$_.homemdb -ne $null} | ForEach-Object ($_.SamAccountName) {$CompleteUPN = $_.SamAccountName + “@contoso.com”; Set-ADUser -Identity $_.DistinguishedName -UserPrincipalName $CompleteUPN}

The command works using the AD module for powershell. What I would like to do it write a script that does the following.

Runs the command above

Only applies changes to users that need it. (I think this applies the setting to all users with the "homemdb")

I was thinking of setting it as a scheduled task on one of the Domain Controllers. Mypowershell skills are lacking at best, so any guidance on how to set this up would be much appreciated. 

Thanks


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>