none
PowerShell Command / Script to add additional Global Administrator as an Owner to a Security Group In Office 365

    Question

  • Hi There,

    I have a requirement as the Office 365 Administrator with the following:

    Anyone, know if there is a command in Power Shell (Script) for Office 365 to add an additional Global Administrator as an Owner to a particular Security Group or all Security Groups or to a Security Group that contains a certain word or phrase.

    1. Add a Global Administrator to ALL Security Groups:

    2. Add a Global Administrator to a Specific Security Group:

    3. Add a Global Administrator to ALL Security Groups that contain a specific Word / Phrase:

    Any suggestions would be helpful.  This has become a necessity for my organisation.

    Thank You in advance.

    Shenil


    Sunday, December 08, 2013 12:34 AM

All replies

  • #Add a Global Administrator to ALL Security Groups:
    $GlobalAdminID = Get-MsolRoleMember -RoleObjectId "62e90394-69f5-4237-9190-012177145e10" | Select EmailAddress
    #$GlobalAdminID
    foreach($id in $GlobalAdminID.EmailAddress)
    {
        
        Get-DistributionGroup | ? {$_.GroupType -eq "Security"}| %{Add-DistributionGroupMember -Identity $_.DisplayName  -Member $id }
    }
    
    #Add a Global Administrator to a Specific Security Group:
    $GlobalAdminID = Get-MsolRoleMember -RoleObjectId "62e90394-69f5-4237-9190-012177145e10" | Select EmailAddress
    foreach($id in $GlobalAdminID.ObjectId)
    {
         Get-DistributionGroup | ? {$_.GroupType -eq "Security" -and $_.DisplayName -eq 'Name1'}| %{Add-DistributionGroupMember -Identity $_.DisplayName  -Member $id }
    }
    
    #Add a Global Administrator to ALL Security Groups that contain a specific Word / Phrase:
    $GlobalAdminID = Get-MsolRoleMember -RoleObjectId "62e90394-69f5-4237-9190-012177145e10" | Select EmailAddress
    foreach($id in $GlobalAdminID.ObjectId)
    {
         Get-DistributionGroup | ? {$_.GroupType -eq "Security" -and $_.DisplayName -like '*Some Phrase*'}| %{Add-DistributionGroupMember -Identity $_.DisplayName  -Member $id }
    }

    Note: I didn't test this - Please test or use -Whatif

    Change RoleObjectID as applicable

    Get-MSOLRole will give company administrator GUID that;s Global Admin ID


    Regards Chen V [MCTS SharePoint 2010]


    • Edited by Chen VMVP Monday, February 23, 2015 11:50 AM
    Monday, February 23, 2015 11:48 AM