1

Using Powershell, how can I get the UserID of an account if I don't know which domain it is in?

For example, I have a Mail-User account called b.newhart and I can fetch information using that as the -identity with the get-recipient command.

But I need to know the UserID which has the domain name attached to it - for example, b.newhart@mydomain.com. This is the UserID that you can see in the Admin panel of Exchange Online.

The reason I need the UserID is so I can use Set-MsolUserPassword on that account. To use this command, I need to specify the -UserPrincipalName which is the UserID. For full o365 accounts (with mail) I can use just the identity, but for Mail-User accounts I need the UserID with the domain name too, not just the identity.

We have very many mail-users from various domains, and the usernames are all standardized first initial + last name. So if I can reset their passwords by just knowing their identity then it would be wonderful.

So, How can I get the the UserID of a Mail-User account? OR how can I reset the password for a Mail-User account without knowing the domain designation?

0

Here it is!

get-recipient -identity b.newhart | select windowsLiveID
#returns b.newhart@mydomain.com

This will fetch the internal email address which is the UserID that can be used in the Set-MsolUserPassword command.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.