Created
June 18, 2018 11:04
-
-
Save chrisobriensp/1c4d18dbda9698259181d5ff647a04cb 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) - completed.
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-VSCode: PowerShell Timer trigger function executed at:$(get-date)"; | |
$currentDate = Get-Date -Format "ddd_dd_MM_hh_mm" | |
$groupPrefix = "COB_AutoCreatedGroup___" | |
$groupName = $groupPrefix + $currentDate | |
Write-Output "Will attempt to create group with name '$($groupName)'" | |
$appid = $env:AppID | |
$client_secret = $env:AppSecret | |
$tenant = $env:Tenant | |
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