How to get UserID of Mail-User via powershell

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?

1
задан 1 March 2017 в 23:16
1 ответ

Вот оно!

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

Будет извлечен внутренний адрес электронной почты, который является идентификатором пользователя, который можно использовать в команде Set-MsolUserPassword .

0
ответ дан 4 December 2019 в 05:08

Теги

Похожие вопросы