Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save chrisobriensp/1c4d18dbda9698259181d5ff647a04cb to your computer and use it in GitHub Desktop.
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.
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