WhoAmI for Office 365

WhoAmI for Office 365

  • 1
  •  
  •  
  •  
  •  
  •  
    1
    Share
WhoAmI for Office 365
4.3 (85%) 4 vote[s]

If you’ve ever struggled to find out who your current session is logged in as when you connected to Office 365, here’s a tidbit to shed some light on it:

(Get-PSSession |?{$_.ComputerName -like “*outlook.com”})[0].RunSpace.ConnectionInfo.Credential.UserName

You can also use RunSpace.OriginalConnectionInfo.Credential.UserName.  The SDK says ConnectionInfo vs OriginalConnectionInfo:

ConnectionInfo – Connection information for remote Runspaces, null for local Runspaces

OriginalConnectionInfo – ConnectionInfo originally supplied by the user

I have found them to have the same output in the context of Office 365 to this point, but if any of my readers stumbles upon a difference, I’d be happy to learn!

Reader Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.