<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>create group graph api REST API Archives - the Sysadmin Channel</title>
	<atom:link href="https://thesysadminchannel.com/tag/create-group-graph-api-rest-api/feed/" rel="self" type="application/rss+xml" />
	<link>https://thesysadminchannel.com/tag/create-group-graph-api-rest-api/</link>
	<description>Documenting My Life as a System Administrator</description>
	<lastBuildDate>Mon, 12 Dec 2022 18:08:54 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.3</generator>
<site xmlns="com-wordpress:feed-additions:1">144174110</site>	<item>
		<title>New-MgGroup: Create A Group in Graph API</title>
		<link>https://thesysadminchannel.com/new-mggroup-create-a-group-in-graph-api/</link>
					<comments>https://thesysadminchannel.com/new-mggroup-create-a-group-in-graph-api/#respond</comments>
		
		<dc:creator><![CDATA[Paul Contreras]]></dc:creator>
		<pubDate>Mon, 12 Dec 2022 18:08:54 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Graph API]]></category>
		<category><![CDATA[Create A Group in Graph API]]></category>
		<category><![CDATA[create azure ad group powershell]]></category>
		<category><![CDATA[create group graph api REST API]]></category>
		<category><![CDATA[New-MgGroup]]></category>
		<guid isPermaLink="false">https://thesysadminchannel.com/?p=4518</guid>

					<description><![CDATA[<p>Groups are essential to the management of resources in any platform and it&#8217;s helpful to use them instead of using individual users. Today we&#8217;re going to cover how to create a group in Graph API using the PowerShell SDK for&#8230; <a href="https://thesysadminchannel.com/new-mggroup-create-a-group-in-graph-api/" class="more-link">Continue Reading <span class="meta-nav">&#8594;</span></a></p>
<p>The post <a href="https://thesysadminchannel.com/new-mggroup-create-a-group-in-graph-api/">New-MgGroup: Create A Group in Graph API</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>Groups are essential to the management of resources in any platform and it&#8217;s helpful to use them instead of using individual users.  Today we&#8217;re going to cover <strong>how to create a group in Graph API</strong> using the PowerShell SDK for us IT Pros.  This specifically goes over the usage of <strong>New-MgGroup</strong> and the various ways you can use it.</p>
<div id="tableofcontents">
<h2>Table Of Contents</h2>
<ul>
<li><a href="#requirements">Requirements</a></li>
<li><a href="#creategrouppowershell">Create A Group in Graph API with New-MgGroup</a></li>
<li><a href="#creategroupowner">Create A Security Group with an Owner</a></li>
<li><a href="#creategroupmember">Create A Group with an Owner and Members</a></li>
<li><a href="#createdyanmicgroup">Create A Dynamic Security Group with Membership Rules</a></li>
<li><a href="#conclusion">Conclusion</a></li>
</ul>
</div>
<div id="requirements" style="scroll-margin-top: 15px;"></div>
<h2>Requirements</h2>
<p>In order to successfully create groups in Graph API, we&#8217;ll need to ensure we have the right permissions needed.  Let&#8217;s touch a bit on what those might be.</p>
<ul>
<li><strong>User Administrator</strong>, <strong>Groups Administrator</strong> or <strong>Global Administrator</strong> Azure AD Role(s)</li>
<li><strong>Microsoft.Graph</strong> PowerShell SDK Module (if not using the REST API)</li>
<li>Graph API Scopes:</li>
<ul>
<li>Delegated: Group.ReadWrite.All, Directory.ReadWrite.All</li>
<li>Application: Group.Create, Group.ReadWrite.All, Directory.ReadWrite.All</li>
</ul>
</ul>
<div id="creategrouppowershell" style="scroll-margin-top: 15px;"></div>
<h2>Create A Group in Graph API with New-MgGroup</h2>
<p>When creating groups in Azure AD, 99% of the time I create security enabled groups because I use them for providing access to specific resources. When I need to create groups with an email address, I use Distribution Lists (or Mail-enabled Security groups) in Exchange.  Personally, I am not a fan of M365 (unified groups) but that&#8217;s a topic for another day.<br />
&nbsp;</p>
<p>Let&#8217;s dig into the code for creating a security group in Azure AD using Graph API.</p>
<pre class="brush: powershell; title: ; notranslate">
$GroupParam = @{
     DisplayName = &quot;SG-SecurityNoOwnerNoMember&quot;
     GroupTypes = @(
     )
     SecurityEnabled     = $true
     IsAssignableToRole  = $false
     MailEnabled         = $false
     MailNickname        = (New-Guid).Guid.Substring(0,10)
}

New-MgGroup -BodyParameter $GroupParam
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMember-1.jpg" target="_blank" rel="noopener"><img fetchpriority="high" decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMember-1.jpg" alt="SG-SecurityNoOwnerNoMember" width="906" height="399" class="aligncenter size-full wp-image-4527" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMember-1.jpg?v=1670439588 906w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMember-1-768x338.jpg?v=1670439588 768w" sizes="(max-width: 906px) 100vw, 906px" /></a></p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMemberProperties.jpg" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMemberProperties.jpg" alt="SG-SecurityNoOwnerNoMemberProperties" width="1025" height="583" class="aligncenter size-full wp-image-4529" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMemberProperties.jpg?v=1670439859 1025w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityNoOwnerNoMemberProperties-768x437.jpg?v=1670439859 768w" sizes="(max-width: 1025px) 100vw, 1025px" /></a></p>
<div id="creategroupowner" style="scroll-margin-top: 15px;"></div>
<h2>Create A Security Group with an Owner</h2>
<p>We got the basics of creating a security group by using the PowerShell SDK and Graph API, but let&#8217;s add on to this by adding an owner to the group.  You can add a Service Principal or a user account as an owner.<br />
&nbsp;</p>
<p>If you want to add a Service Principal, you&#8217;ll need to know the Service Principal Id so we can bind it to the parameters.  If you&#8217;re looking to add a user, you can use the UserPrincipalName, or UserId.  Let&#8217;s do this now.</p>
<pre class="brush: powershell; title: ; notranslate">
$GroupParam = @{
     DisplayName = &quot;SG-SecurityGroupWithOwner&quot;
     GroupTypes = @(
     )
     SecurityEnabled     = $true
     IsAssignableToRole  = $false
     MailEnabled         = $false
     MailNickname        = (New-Guid).Guid.Substring(0,10)
     &quot;Owners@odata.bind&quot; = @(
         &quot;https://graph.microsoft.com/v1.0/me&quot;,
         &quot;https://graph.microsoft.com/v1.0/users/luke@thesysadminchannel.com&quot;,
         &quot;https://graph.microsoft.com/v1.0/users/647e9c5e-xxxx-xxxx-xxxx-xxxxxxxxxxxx&quot;
         &quot;https://graph.microsoft.com/v1.0/servicePrincipals/50ded543-xxxx-xxxx-xxxx-xxxxxxxxxxxx&quot;
     )
}
PS C:\&gt; New-MgGroup -BodyParameter $GroupParam
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwner.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwner.png" alt="SG-SecurityGroupwithOwner" width="947" height="482" class="aligncenter size-full wp-image-4531" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwner.png?v=1670440938 947w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwner-768x391.png?v=1670440938 768w" sizes="(max-width: 947px) 100vw, 947px" /></a></p>
<div id="creategroupmember" style="scroll-margin-top: 15px;"></div>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerProperties.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerProperties.png" alt="SG-SecurityGroupwithOwnerProperties" width="852" height="389" class="aligncenter size-full wp-image-4532" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerProperties.png?v=1670441205 852w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerProperties-768x351.png?v=1670441205 768w" sizes="(max-width: 852px) 100vw, 852px" /></a></p>
<h2>Create A Group with an Owner and Members</h2>
<p>Next up, let&#8217;s create a group with owners and a couple of members.</p>
<pre class="brush: powershell; title: ; notranslate">
$GroupParam = @{
     DisplayName = &quot;SG-SecurityGroupWithOwnerAndMembers&quot;
     GroupTypes = @(
     )
     SecurityEnabled     = $true
     IsAssignableToRole  = $false
     MailEnabled         = $false
     MailNickname        = (New-Guid).Guid.Substring(0,10)
     &quot;Owners@odata.bind&quot; = @(
         &quot;https://graph.microsoft.com/v1.0/me&quot;,
         &quot;https://graph.microsoft.com/v1.0/users/luke@thesysadminchannel.com&quot;
     )
     &quot;Members@odata.bind&quot; = @(
         &quot;https://graph.microsoft.com/v1.0/me&quot;,
         &quot;https://graph.microsoft.com/v1.0/users/buzz@thesysadminchannel.com&quot;
     )
 }
New-MgGroup -BodyParameter $GroupParam
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerAndMembers.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerAndMembers.png" alt="SG-SecurityGroupwithOwnerAndMembers" width="981" height="518" class="aligncenter size-full wp-image-4537" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerAndMembers.png?v=1670442290 981w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerAndMembers-768x406.png?v=1670442290 768w" sizes="(max-width: 981px) 100vw, 981px" /></a></p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerAndMembersProperties.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-SecurityGroupwithOwnerAndMembersProperties.png" alt="SG-SecurityGroupwithOwnerAndMembersProperties" width="820" height="398" class="aligncenter size-full wp-image-4538" /></a></p>
<div id="createdyanmicgroup" style="scroll-margin-top: 15px;"></div>
<h2>Create A Dynamic Security Group with Membership Rules</h2>
<p>Last and certainly not least, let&#8217;s get started with creating dynamic groups to add members with specific criteria.  In my case, I am just going to add a statement where the account is enabled and the UPN is mine.</p>
<pre class="brush: powershell; title: ; notranslate">
$GroupParam = @{
     DisplayName = &quot;SG-DynamicSecurityGroup&quot;
     GroupTypes = @(
         'DynamicMembership'
     )
     SecurityEnabled     = $true
     IsAssignableToRole  = $false
     MailEnabled         = $false
     membershipRuleProcessingState = 'On'
     MembershipRule = '(user.accountEnabled -eq true) and (user.userPrincipalName -eq &quot;paul@thesysadminchannel.com&quot;)'
     MailNickname        = (New-Guid).Guid.Substring(0,10)
     &quot;Owners@odata.bind&quot; = @(
         &quot;https://graph.microsoft.com/v1.0/me&quot;
     )
 }

New-MgGroup -BodyParameter $GroupParam
</pre>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroup.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroup.png" alt="SG-DynamicSecurityGroup" width="1099" height="517" class="aligncenter size-full wp-image-4541" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroup.png?v=1670442984 1099w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroup-1024x482.png?v=1670442984 1024w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroup-768x361.png?v=1670442984 768w" sizes="(max-width: 1099px) 100vw, 1099px" /></a></p>
<p><a href="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroupProperties.png" target="_blank" rel="noopener"><img decoding="async" src="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroupProperties.png" alt="SG-DynamicSecurityGroupProperties" width="975" height="556" class="aligncenter size-full wp-image-4542" srcset="https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroupProperties.png?v=1670443009 975w, https://thesysadminchannel.com/wp-content/uploads/2022/12/SG-DynamicSecurityGroupProperties-768x438.png?v=1670443009 768w" sizes="(max-width: 975px) 100vw, 975px" /></a></p>
<div id="conclusion" style="scroll-margin-top: 15px;"></div>
<h2>Conclusion</h2>
<p>Hopefully this article was able to show you how to create a group in Graph API using the New-MgGroup cmdlet that comes with the Microsoft.Graph PowerShell SDK.</p>
<p>The post <a href="https://thesysadminchannel.com/new-mggroup-create-a-group-in-graph-api/">New-MgGroup: Create A Group in Graph API</a> appeared first on <a href="https://thesysadminchannel.com">the Sysadmin Channel</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://thesysadminchannel.com/new-mggroup-create-a-group-in-graph-api/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">4518</post-id>	</item>
	</channel>
</rss>
