Home
%3CLINGO-SUB%20id%3D%22lingo-sub-1032554%22%20slang%3D%22en-US%22%3EStep-by-Step%3A%20Managing%20Groups%20via%20Azure%20Active%20Directory%20PowerShell%20for%20Graph%20module%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1032554%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20my%20previous%20blog%20post%2C%20I%20explained%20how%20we%20can%20manage%20Azure%20AD%20users%20by%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAzure%20Active%20Directory%20PowerShell%20for%20Graph%20module%3C%2FSTRONG%3E.%20In%20there%20I%20also%20shared%20many%20examples.%20You%20can%20access%20it%20via%3CSPAN%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FITOps-Talk-Blog%2FStep-by-Step-Managing-Users-via-the-Azure-Active-Directory%2Fba-p%2F961128%22%20target%3D%22_self%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FITOps-Talk-Blog%2FStep-by-Step-Managing-Users-via-the-Azure-Active-Directory%2Fba-p%2F961128%3C%2FA%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20blog%20post%20I%20am%20going%20to%20show%20how%20we%20can%20manage%20Groups%2C%20using%20same%20method.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAzure%20AD%20Groups%20also%20works%20similar%20to%20on-premises%20AD%20groups.%20It%20can%20use%20to%20manage%20permissions%20in%20effective%20manner.%20In%20Hybrid%20environment%20there%20will%20be%20cloud-only%20groups%20as%20well%20as%20synced%20groups%20from%20on-premises%20AD%20environment.%20In%20this%20section%20we%20are%20going%20to%20look%20in%20to%20group%20management%20using%20Azure%20Active%20Directory%20PowerShell%20for%20Graph%20module.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20start%20with%20listing%20groups.%26nbsp%3BWe%20can%20search%20for%20a%20group%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-SearchString%20%22sg%22%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%3CSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ESearchString%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20used%20to%20define%20the%20search%20criteria.%20Above%20example%20will%20list%20down%20any%20group%20containing%20%E2%80%9C%3CSTRONG%3Esg%3C%2FSTRONG%3E%E2%80%9D%20in%20Display%20name%20field.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158873iC768C8DE8551097B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%2216_7.png%22%20title%3D%2216_7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20search%20result%2C%20we%20can%20see%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EobjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efor%20the%20group.%20Once%20we%20know%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%2C%20we%20can%20see%20the%20details%20of%20the%20group%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-ObjectId%2093291438-be19-472e-a1d6-9b178b7ac619%20%7C%20fl%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20hybrid%20environment%2C%20there%20will%20be%20security%20groups%20which%20is%20synced%20from%20on-premises%20Active%20Directory.%20We%20can%20filter%20this%20groups%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-Filter%20'DirSyncEnabled%20eq%20true'%20%7C%20select%20ObjectId%2CDisplayName%2CLastDirSyncTime%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20example%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ELastDirSyncTime%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecolumn%20display%20the%20last%20successful%20sync%20time%20of%20the%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20filter%20cloud-only%20groups%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-All%20%24true%20%7C%20where-Object%20%7B%24_.OnPremisesSecurityIdentifier%20-eq%20%24null%7D%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%20we%20are%20using%20attribute%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EOnPremisesSecurityIdentifier%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20filter%20the%20groups.%20This%20attribute%20only%20has%20value%20if%20it%20is%20synced%20from%20on-premises%20AD.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20view%20group%20memberships%20by%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroupMember%20-ObjectId%202a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%20we%20are%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20uniquely%20identify%20the%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20add%20members%20to%20group%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdd-AzureADGroupMember%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecmdlet.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAdd-AzureADGroupMember%20-ObjectId%202a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a%20-RefObjectId%20a6aeced9-909e-4684-8712-d0f242451338%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20group%20and%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERefObjectId%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Evalue%20represent%20the%20user.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20remove%20a%20member%20from%20group%20by%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERemove-AzureADGroupMember%20-ObjectId%202a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a%20-MemberId%20a6aeced9-909e-4684-8712-d0f242451338%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20group%20and%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMemberId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20user%E2%80%99s%20Object%20Id.%3C%2FP%3E%0A%3CP%3EWe%20also%20can%20combine%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdd-AzureADGroupMember%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecmdlet%20with%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EGet-AzureADUser%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecmdlet%20to%20add%20bulk%20users%20to%20a%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20below%20script%2C%20I%20used%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EGet-AzureADUser%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Ecmdlet%20to%20search%20users%20in%20Marketing%20Department.%20Then%20used%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdd-AzureADGroupMember%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20add%20those%20users%20to%20Sales%20group%20as%20members.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%23%23%23%23%23%23%23Script%20to%20Add%20Multiple%20users%20to%20Security%20Group%23%23%23%23%23%23%23%23%23%23%23%23%23%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EImport-Module%20AzureAD%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EConnect-AzureAD%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%23%23%23%23%23%20Search%20for%20users%20in%20Marketing%20Department%20%23%23%23%23%23%23%23%23%23%23%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADUser%20-All%20%24true%20-Filter%20%22Department%20eq%20'Marketing'%22%20%7C%20select%20ObjectId%20%7C%20Out-File%20-FilePath%20C%3A%5Csalesusers.txt%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%23%23%23%23%23Add%20Users%20to%20Sales%20Group%23%23%23%23%23%23%23%23%23%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E(Get-Content%20%22C%3A%5Csalesusers.txt%22%20%7C%20select-object%20-skip%203)%20%7C%20ForEach%20%7B%20Add-AzureADGroupMember%20-ObjectId%20f9f51d29-e093-4e57-ad79-2fc5ae3517db%20-RefObjectId%20%24_%20%7D%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3BIn%20hybrid%20environment%2C%20the%20security%20groups%20are%20mainly%20synced%20from%20on-premises%20AD.%20But%20there%20can%20be%20requirements%20for%20cloud-only%20groups%20as%20well.%20We%20can%20create%20cloud-only%20group%20by%20using%2C%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENew-AzureADGroup%20-DisplayName%20%22REBELADMIN%20Sales%20Team%22%20-MailEnabled%20%24false%20-MailNickName%20%22salesteam%22%20-SecurityEnabled%20%24true%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPreceding%20command%20creates%20a%20security%20group%20called%20%22%3CSTRONG%3EREBELADMIN%20Sales%20Team%3C%2FSTRONG%3E%22.%20This%20group%20is%20not%20a%20mail%20enabled%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20remove%20Azure%20AD%20group%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERemove-AzureADGroup%20-ObjectId%207592b555-343d-4f73-a6f1-2270d7cf014f%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObject%20ID%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20defines%20the%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EApart%20from%20security%20groups%2C%20Azure%20AD%20also%20have%20predefined%20administrative%20roles%20which%20can%20use%20to%20assign%20access%20permissions%20to%20Azure%20AD%20and%20other%20cloud%20services.%20There%20are%20more%20than%2035%20predefined%20administrative%20roles.%20Each%20of%20role%20have%20their%20own%20set%20of%20permissions.%20More%20details%20about%20this%20roles%20can%20find%20in%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fusers-groups-roles%2Fdirectory-assign-admin-roles%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fusers-groups-roles%2Fdirectory-assign-admin-roles%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20list%20down%20all%20the%20administrative%20roles%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADDirectoryRoleTemplate%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20default%2C%20only%20few%20administrative%20roles%20are%20enabled.%20We%20can%20list%20these%20roles%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADDirectoryRole%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20834px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158874iAC497D8294082D45%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%2216_9.png%22%20title%3D%2216_9.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3ECompany%20Administrator%20directory%20role%20represent%20the%20Azure%20AD%20Global%20Administrators.%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20enable%20Administrative%20role%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EEnable-AzureADDirectoryRole%20-RoleTemplateId%20e6d1a23a-da11-4be4-9570-befc86d067a7%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERoleTemplateId%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Evalue%20represent%20the%20Administrative%20Role.%3C%2FP%3E%0A%3CP%3EWe%20can%20assign%20administrative%20role%20to%20a%20user%20by%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAdd-AzureADDirectoryRoleMember%20-ObjectId%20b63c1671-625a-4a80-8bae-6487423909ca%20-RefObjectId%20581c7265-c8cc-493b-9686-771b2f10a77e%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20Administrative%20Role.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERefObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20object%20id%20value%20of%20the%20user.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20list%20down%20members%20of%20Administrative%20role%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADDirectoryRoleMember%20-ObjectId%2036b9ac02-9dfc-402a-8d44-ba2d8995dc06%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Erepresent%20the%20Administrative%20role.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20remove%20a%20member%20from%20the%20role%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERemove-AzureADDirectoryRoleMember%20-ObjectId%2036b9ac02-9dfc-402a-8d44-ba2d8995dc06%20-MemberId%20165ebcb7-f07d-42d2-a52e-90f44e71e4a1%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMemberId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20equal%20to%20user%E2%80%99s%20object%20id%20value.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-1032554%22%20slang%3D%22en-US%22%3E%3CP%3EIn%20my%20previous%20blog%20post%2C%20I%20explained%20how%20we%20can%20manage%20Azure%20AD%20users%20by%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAzure%20Active%20Directory%20PowerShell%20for%20Graph%20module%3C%2FSTRONG%3E.%20In%20there%20I%20also%20shared%20many%20examples.%20You%20can%20access%20it%20via%3CSPAN%3E%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FITOps-Talk-Blog%2FStep-by-Step-Managing-Users-via-the-Azure-Active-Directory%2Fba-p%2F961128%22%20target%3D%22_self%22%3Ehttps%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FITOps-Talk-Blog%2FStep-by-Step-Managing-Users-via-the-Azure-Active-Directory%2Fba-p%2F961128%3C%2FA%3E%3C%2FSPAN%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20this%20blog%20post%20I%20am%20going%20to%20show%20how%20we%20can%20manage%20Groups%2C%20using%20same%20method.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EAzure%20AD%20Groups%20also%20works%20similar%20to%20on-premises%20AD%20groups.%20It%20can%20use%20to%20manage%20permissions%20in%20effective%20manner.%20In%20Hybrid%20environment%20there%20will%20be%20cloud-only%20groups%20as%20well%20as%20synced%20groups%20from%20on-premises%20AD%20environment.%20In%20this%20section%20we%20are%20going%20to%20look%20in%20to%20group%20management%20using%20Azure%20Active%20Directory%20PowerShell%20for%20Graph%20module.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELet%E2%80%99s%20start%20with%20listing%20groups.%26nbsp%3BWe%20can%20search%20for%20a%20group%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-SearchString%20%22sg%22%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%3CSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3ESearchString%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20used%20to%20define%20the%20search%20criteria.%20Above%20example%20will%20list%20down%20any%20group%20containing%20%E2%80%9C%3CSTRONG%3Esg%3C%2FSTRONG%3E%E2%80%9D%20in%20Display%20name%20field.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20999px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158873iC768C8DE8551097B%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%2216_7.png%22%20title%3D%2216_7.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20search%20result%2C%20we%20can%20see%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EobjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Efor%20the%20group.%20Once%20we%20know%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%2C%20we%20can%20see%20the%20details%20of%20the%20group%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-ObjectId%2093291438-be19-472e-a1d6-9b178b7ac619%20%7C%20fl%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20hybrid%20environment%2C%20there%20will%20be%20security%20groups%20which%20is%20synced%20from%20on-premises%20Active%20Directory.%20We%20can%20filter%20this%20groups%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-Filter%20'DirSyncEnabled%20eq%20true'%20%7C%20select%20ObjectId%2CDisplayName%2CLastDirSyncTime%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20example%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ELastDirSyncTime%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecolumn%20display%20the%20last%20successful%20sync%20time%20of%20the%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20filter%20cloud-only%20groups%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroup%20-All%20%24true%20%7C%20where-Object%20%7B%24_.OnPremisesSecurityIdentifier%20-eq%20%24null%7D%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%20we%20are%20using%20attribute%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EOnPremisesSecurityIdentifier%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20filter%20the%20groups.%20This%20attribute%20only%20has%20value%20if%20it%20is%20synced%20from%20on-premises%20AD.%26nbsp%3B%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20view%20group%20memberships%20by%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADGroupMember%20-ObjectId%202a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%20we%20are%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20uniquely%20identify%20the%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20add%20members%20to%20group%20using%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdd-AzureADGroupMember%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecmdlet.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAdd-AzureADGroupMember%20-ObjectId%202a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a%20-RefObjectId%20a6aeced9-909e-4684-8712-d0f242451338%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20group%20and%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERefObjectId%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Evalue%20represent%20the%20user.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20remove%20a%20member%20from%20group%20by%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERemove-AzureADGroupMember%20-ObjectId%202a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a%20-MemberId%20a6aeced9-909e-4684-8712-d0f242451338%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20group%20and%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMemberId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20user%E2%80%99s%20Object%20Id.%3C%2FP%3E%0A%3CP%3EWe%20also%20can%20combine%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdd-AzureADGroupMember%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecmdlet%20with%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EGet-AzureADUser%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Ecmdlet%20to%20add%20bulk%20users%20to%20a%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20below%20script%2C%20I%20used%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EGet-AzureADUser%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Ecmdlet%20to%20search%20users%20in%20Marketing%20Department.%20Then%20used%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EAdd-AzureADGroupMember%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eto%20add%20those%20users%20to%20Sales%20group%20as%20members.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%23%23%23%23%23%23%23Script%20to%20Add%20Multiple%20users%20to%20Security%20Group%23%23%23%23%23%23%23%23%23%23%23%23%23%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EImport-Module%20AzureAD%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EConnect-AzureAD%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%23%23%23%23%23%20Search%20for%20users%20in%20Marketing%20Department%20%23%23%23%23%23%23%23%23%23%23%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADUser%20-All%20%24true%20-Filter%20%22Department%20eq%20'Marketing'%22%20%7C%20select%20ObjectId%20%7C%20Out-File%20-FilePath%20C%3A%5Csalesusers.txt%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%23%23%23%23%23Add%20Users%20to%20Sales%20Group%23%23%23%23%23%23%23%23%23%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E(Get-Content%20%22C%3A%5Csalesusers.txt%22%20%7C%20select-object%20-skip%203)%20%7C%20ForEach%20%7B%20Add-AzureADGroupMember%20-ObjectId%20f9f51d29-e093-4e57-ad79-2fc5ae3517db%20-RefObjectId%20%24_%20%7D%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3BIn%20hybrid%20environment%2C%20the%20security%20groups%20are%20mainly%20synced%20from%20on-premises%20AD.%20But%20there%20can%20be%20requirements%20for%20cloud-only%20groups%20as%20well.%20We%20can%20create%20cloud-only%20group%20by%20using%2C%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ENew-AzureADGroup%20-DisplayName%20%22REBELADMIN%20Sales%20Team%22%20-MailEnabled%20%24false%20-MailNickName%20%22salesteam%22%20-SecurityEnabled%20%24true%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EPreceding%20command%20creates%20a%20security%20group%20called%20%22%3CSTRONG%3EREBELADMIN%20Sales%20Team%3C%2FSTRONG%3E%22.%20This%20group%20is%20not%20a%20mail%20enabled%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20remove%20Azure%20AD%20group%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERemove-AzureADGroup%20-ObjectId%207592b555-343d-4f73-a6f1-2270d7cf014f%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObject%20ID%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20defines%20the%20group.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EApart%20from%20security%20groups%2C%20Azure%20AD%20also%20have%20predefined%20administrative%20roles%20which%20can%20use%20to%20assign%20access%20permissions%20to%20Azure%20AD%20and%20other%20cloud%20services.%20There%20are%20more%20than%2035%20predefined%20administrative%20roles.%20Each%20of%20role%20have%20their%20own%20set%20of%20permissions.%20More%20details%20about%20this%20roles%20can%20find%20in%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fusers-groups-roles%2Fdirectory-assign-admin-roles%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%20target%3D%22_blank%22%3Ehttps%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Factive-directory%2Fusers-groups-roles%2Fdirectory-assign-admin-roles%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20list%20down%20all%20the%20administrative%20roles%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADDirectoryRoleTemplate%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EBy%20default%2C%20only%20few%20administrative%20roles%20are%20enabled.%20We%20can%20list%20these%20roles%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADDirectoryRole%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20834px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F158874iAC497D8294082D45%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%2216_9.png%22%20title%3D%2216_9.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%3CEM%3E%3CSTRONG%3ECompany%20Administrator%20directory%20role%20represent%20the%20Azure%20AD%20Global%20Administrators.%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20enable%20Administrative%20role%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EEnable-AzureADDirectoryRole%20-RoleTemplateId%20e6d1a23a-da11-4be4-9570-befc86d067a7%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERoleTemplateId%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Evalue%20represent%20the%20Administrative%20Role.%3C%2FP%3E%0A%3CP%3EWe%20can%20assign%20administrative%20role%20to%20a%20user%20by%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EAdd-AzureADDirectoryRoleMember%20-ObjectId%20b63c1671-625a-4a80-8bae-6487423909ca%20-RefObjectId%20581c7265-c8cc-493b-9686-771b2f10a77e%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Evalue%20represent%20the%20Administrative%20Role.%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3ERefObjectId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20the%20object%20id%20value%20of%20the%20user.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20list%20down%20members%20of%20Administrative%20role%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3EGet-AzureADDirectoryRoleMember%20-ObjectId%2036b9ac02-9dfc-402a-8d44-ba2d8995dc06%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20above%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EObjectId%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FSTRONG%3Erepresent%20the%20Administrative%20role.%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20remove%20a%20member%20from%20the%20role%20using%2C%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ERemove-AzureADDirectoryRoleMember%20-ObjectId%2036b9ac02-9dfc-402a-8d44-ba2d8995dc06%20-MemberId%20165ebcb7-f07d-42d2-a52e-90f44e71e4a1%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20preceding%20command%2C%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CSTRONG%3EMemberId%3C%2FSTRONG%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eis%20equal%20to%20user%E2%80%99s%20object%20id%20value.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1032554%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EDishan%20Francis%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EPowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Senior Member

In my previous blog post, I explained how we can manage Azure AD users by using Azure Active Directory PowerShell for Graph module. In there I also shared many examples. You can access it via https://techcommunity.microsoft.com/t5/ITOps-Talk-Blog/Step-by-Step-Managing-Users-via-the-Azure-Act... 

 

In this blog post I am going to show how we can manage Groups, using same method. 

 

Azure AD Groups also works similar to on-premises AD groups. It can use to manage permissions in effective manner. In Hybrid environment there will be cloud-only groups as well as synced groups from on-premises AD environment. In this section we are going to look in to group management using Azure Active Directory PowerShell for Graph module. 

 

Let’s start with listing groups. We can search for a group using,

 

Get-AzureADGroup -SearchString "sg"

 

In above command, SearchString is used to define the search criteria. Above example will list down any group containing “sg” in Display name field. 

 

16_7.png

In search result, we can see the objectId for the group. Once we know the ObjectId, we can see the details of the group using,

 

Get-AzureADGroup -ObjectId 93291438-be19-472e-a1d6-9b178b7ac619 | fl

 

In hybrid environment, there will be security groups which is synced from on-premises Active Directory. We can filter this groups using,

 

Get-AzureADGroup -Filter 'DirSyncEnabled eq true' | select ObjectId,DisplayName,LastDirSyncTime

 

In above example, LastDirSyncTime column display the last successful sync time of the group. 

We can filter cloud-only groups using,

 

Get-AzureADGroup -All $true | where-Object {$_.OnPremisesSecurityIdentifier -eq $null}

 

In preceding command, we are using attribute OnPremisesSecurityIdentifier to filter the groups. This attribute only has value if it is synced from on-premises AD.  

We can view group memberships by using,

 

Get-AzureADGroupMember -ObjectId 2a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a

 

In above command, we are using ObjectId to uniquely identify the group. 

We can add members to group using Add-AzureADGroupMember cmdlet. 

 

Add-AzureADGroupMember -ObjectId 2a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a -RefObjectId a6aeced9-909e-4684-8712-d0f242451338

 

In preceding command, ObjectId value represent the group and RefObjectId value represent the user. 

 

We can remove a member from group by using,

 

Remove-AzureADGroupMember -ObjectId 2a11d5ee-8383-44d1-9fbd-85cb4dcc2d5a -MemberId a6aeced9-909e-4684-8712-d0f242451338

 

In preceding command, ObjectId value represent the group and MemberId value represent the user’s Object Id.

We also can combine Add-AzureADGroupMember cmdlet with Get-AzureADUser cmdlet to add bulk users to a group. 

In below script, I used Get-AzureADUser cmdlet to search users in Marketing Department. Then used Add-AzureADGroupMember to add those users to Sales group as members. 

 

#######Script to Add Multiple users to Security Group#############

Import-Module AzureAD

Connect-AzureAD

##### Search for users in Marketing Department ##########

Get-AzureADUser -All $true -Filter "Department eq 'Marketing'" | select ObjectId | Out-File -FilePath C:\salesusers.txt

#####Add Users to Sales Group#########

(Get-Content "C:\salesusers.txt" | select-object -skip 3) | ForEach { Add-AzureADGroupMember -ObjectId f9f51d29-e093-4e57-ad79-2fc5ae3517db -RefObjectId $_ }

 

 In hybrid environment, the security groups are mainly synced from on-premises AD. But there can be requirements for cloud-only groups as well. We can create cloud-only group by using, 

 

New-AzureADGroup -DisplayName "REBELADMIN Sales Team" -MailEnabled $false -MailNickName "salesteam" -SecurityEnabled $true

 

Preceding command creates a security group called "REBELADMIN Sales Team". This group is not a mail enabled group. 

We can remove Azure AD group using,

 

Remove-AzureADGroup -ObjectId 7592b555-343d-4f73-a6f1-2270d7cf014f

 

In above, Object ID value defines the group. 

Apart from security groups, Azure AD also have predefined administrative roles which can use to assign access permissions to Azure AD and other cloud services. There are more than 35 predefined administrative roles. Each of role have their own set of permissions. More details about this roles can find in https://docs.microsoft.com/en-us/azure/active-directory/users-groups-roles/directory-assign-admin-ro...

We can list down all the administrative roles using,

 

Get-AzureADDirectoryRoleTemplate

 

By default, only few administrative roles are enabled. We can list these roles using,

 

Get-AzureADDirectoryRole

 

16_9.png

Company Administrator directory role represent the Azure AD Global Administrators.

 

We can enable Administrative role using,

 

Enable-AzureADDirectoryRole -RoleTemplateId e6d1a23a-da11-4be4-9570-befc86d067a7

 

In above command, RoleTemplateId value represent the Administrative Role.

We can assign administrative role to a user by using,

 

Add-AzureADDirectoryRoleMember -ObjectId b63c1671-625a-4a80-8bae-6487423909ca -RefObjectId 581c7265-c8cc-493b-9686-771b2f10a77e

 

In preceding command, ObjectId value represent the Administrative Role. RefObjectId is the object id value of the user. 

We can list down members of Administrative role using,

 

Get-AzureADDirectoryRoleMember -ObjectId 36b9ac02-9dfc-402a-8d44-ba2d8995dc06

 

In above command, ObjectId represent the Administrative role. 

We can remove a member from the role using,

 

Remove-AzureADDirectoryRoleMember -ObjectId 36b9ac02-9dfc-402a-8d44-ba2d8995dc06 -MemberId 165ebcb7-f07d-42d2-a52e-90f44e71e4a1

 

In preceding command, MemberId is equal to user’s object id value.