I need to set the immutable ID of all users to their UPN. I have a two line powershell script to do it for a single user. Essentially i want to make this recursive and to run for every user in the tenant. I'm newish to powershell with office 365. I'm not sure how to make this happen.
get-msoluser -UserPrincipalName "[email protected]" | foreach {$_.UserPrincipalName} | Set-Variable UPN1
set-msoluser -UserPrincipalName "[email protected]" -immutableID “$UPN1”
You already had the work in your two lines, just modified to get all MSOLUsers and process each user. This could take a while if you have lots of users. You may want to look into filters for Get-MSOLUser before you run something like this.
I'm not 100% sure about the curly quotes for you immutableID in your example
“$UPN1”
. Did this even need to be quoted?