Created
June 11, 2018 19:44
-
-
Save chrisobriensp/5201d6ba9bd8ce6741ae9cf7288e1906 to your computer and use it in GitHub Desktop.
Uses PnP PowerShell to create an Office 365 Group (using an AAD app for Graph authentication)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Write-Output "COB-O365-Group-Creator: PowerShell function executed at:$(get-date)" | |
| $appid = "[TODO - ENTER YOUR APP ID HERE]" | |
| $client_secret = "[TODO - ENTER YOUR APP SECRET KEY HERE]" | |
| $tenant = "[TODO - ENTER YOUR TENANT PREFIX HERE].onmicrosoft.com" | |
| $currentDate = Get-Date -Format "ddd_dd_MM" | |
| $groupPrefix = "COB_AutoCreatedGroup___" | |
| $groupName = $groupPrefix + $currentDate | |
| Write-Output "Will attempt to create group with name '$($groupName)'" | |
| Connect-PnPOnline -AppId $appid -AppSecret $client_secret -AADDomain $tenant | |
| try { | |
| $group = New-PnPUnifiedGroup -DisplayName $groupName -Description $groupName -MailNickname $groupName -IsPrivate -Verbose | |
| Write-Output "Successfully created group '$($groupName)'" | |
| } catch { | |
| Write-Error "Unable to create Group - exception details: $($_)" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment