How do I get my username for Exchange with PowerShell

How do I get my username for Exchange with PowerShell



Is there any command, or other way, that I can get the username that I have used for logging in to the Exchange-module in PowerShell?



For clarification:
This functionality is to be used in a script that will handle permissions for a group of Exchange-admins. And to avoid having to type their admin-accountnames each time they run the script, it would be great if the script could get the name of the account they used when logging in with the PowerShell Exchange-module.




2 Answers
2



You can get your username in the following code:


Get-Mailbox -ResultSize Unlimited | ForEach
Select-Object @label="User" ; expression=$user,DeviceOS, lastsuccesssync



how to get exact user name from get-mobiledevicestatistics in powershell






Sorry for not mentioning this, but since we have a huge number of users, get them all is not an option. Plus, testing the code gives a list of evert user, their device (if they have any) and last successful sync.

– Smorkster
Sep 18 '18 at 9:56






you can try the following code : "Get-Mailbox -ResultSize unlimited | Format-Table -Auto DisplayName, LitigationHoldEnabled" reference from : docs.microsoft.com/en-us/exchange/recipients-in-exchange-online/…

– Alina Li
Sep 18 '18 at 10:30



I never found an clear answer for this, so I insteed used my domain-AD username to search for correct useraccount.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




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

Popular posts from this blog

PHP code is not being executed, instead code shows on the page

Administrative divisions of China

Cardinality of the set of algorithms