title: Create Unified and Dynamic Membership Office 365 group Via Powershell in AzureAD
body: <p>In the GUI of Azure it is really easy to do this you simply create a new office 365 group and set dynamic Rules but it seems difficult to do via powershell closest i can get is using the following Powershell line. it seems to error out on the Group types portion. I can't seem to get it to create a group with both types, My guess is am just not formatting it correctly. I am using the AzureADPreview module at version 2.0.2.85 since the normal AzureAD module does not work at all for this.</p>
  
  <pre><code>New-AzureADMSGroup -DisplayName "name" -Description "description" -MailEnabled $True -MailNickName "MailName" -SecurityEnabled $True -GroupTypes 'Unified, DynamicMembership' -MembershipRule '(user.userPrincipalName -contains "somafeasokdfalksjfjlkads")' -MembershipRuleProcessingState $true
  </code></pre>
  
  <p>give me the error</p>
  
  <pre><code>Code: Request_BadRequest
  Message: Invalid value specified for property 'groupTypes' of resource 'Group'.
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/wba28.png" rel="nofollow noreferrer">GUI Creation</a></p>
  
  <p><a href="https://i.stack.imgur.com/W9HyG.png" rel="nofollow noreferrer">Powershell Get</a></p>
  
  <p><a href="https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureadmsgroup?view=azureadps-2.0" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/powershell/module/azuread/new-azureadmsgroup?view=azureadps-2.0</a></p>
  
  <p>The gist is I am trying to find a powershell way to get a Azure group like the second photo. Ie both dynamic and unified.</p>