New-O365Group
Azure AD: Creates a new security group
#Requires -Version 5.1
#Requires -Modules AzureAD
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$GroupName,
[string]$Description
)
Process {
try {
if ([System.String]::IsNullOrEmpty($Description)) {
$Description = ' '
}
$grp = New-AzureADGroup -DisplayName $GroupName -SecurityEnabled $true -Description $Description -MailEnabled $false -MailNickName 'NotSet' -ErrorAction Stop | Select-Object *
if ($null -ne $grp) {
[PSCustomObject]@{
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
Status = "Success"
DisplayName = $grp.DisplayName
ObjectId = $grp.ObjectId
Message = "Group '$GroupName' created"
}
}
else { throw "Group not created" }
}
catch { throw }
}Display name of the new group
Optional description for the group