Method to obtain O365 group membership via PS script for current AAD user.

For local AD you can easily obtain your current group memberships via CLI but for Office 365 \ Azure Active Directory, this seems to require Get-MSOL for pretty much everything.

That requires the MSOnline Azure module to be installed and when the script runs the user will be visually prompted for O365 credentials.

Not sure if there’s any way around this.
Ideally, there would be some sort of credential digest that feeds the currently signed in AAD user credential to MSOL allowing the script to bypass the pop-up.

Any ideas? Thank you!

Sets the context and credentials to connect to Microsoft Online and to the Active Directory Federation Services 2.0 server.

  1. if AD FS is still running, use the Set-MsolADFSContext the cmdlet to specify the server on which AD FS is running.
for example: Set-MsolADFSContext –Computer <ServerName>

For more information about the Set-MsolADFSContext cmdlet, see [Set-MsolADFSContext][1].

  1. If AD FS is not running, use the Set-MsolDomainAuthentication cmdlet to change the domain to a managed domain.

for example:

Set-MsolDomainAuthentication -DomainName <DomainName> -Authentication Managed

For more info about the Set-MsolDomainAuthentication cmdlet, see [Set-MsolDomainAuthentication][1].

Hope it helps.

Hello Evila.
I ran the Set-MsolDomainAuthentication -DomainName < DomainName> -Authentication Managed command but after closing the PS window and performing a Connect-MsolService the credentials popup is shown again.

I guess I didn’t mention that I’m looking for a way to make it persistent. (After a reboot)