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

Welcome Forums General PowerShell Q&A Method to obtain O365 group membership via PS script for current AAD user.

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 month ago.

  • Author
    Posts
  • #170743

    Participant
    Topics: 1
    Replies: 1
    Points: 20
    Rank: Member

    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!

  • #170836

    Participant
    Topics: 0
    Replies: 44
    Points: 235
    Helping Hand
    Rank: Participant

    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

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

    2. 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.

  • #170953

    Participant
    Topics: 1
    Replies: 1
    Points: 20
    Rank: Member

    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)

You must be logged in to reply to this topic.