Functions/New-GSuiteGroup.ps1
<#
.SYNOPSIS This function creates a GSuite group. #> function New-GSuiteGroup { [CmdletBinding(PositionalBinding=$false)] [OutputType([PSCustomObject])] param ( # The name for the group. [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String]$name, # The primary email address for the group. [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [String]$primaryEmailAddress ) # Validate that the 'connection' has been established and the group access token exists Assert-GSuiteConnection -Scope "Group" # Prepare REST call parameters $invokeRestMethodParams = @{ Uri = "https://www.googleapis.com/admin/directory/v1/groups" Method = "POST" Headers = @{ "Content-Type" = "application/json" Accept = "application/json" Authorization = "Bearer $($Global:GSuiteAccessTokensHashTable.Group)" } Body = @{ name = $name email = $primaryEmailAddress } | ConvertTo-Json } # Invoke the REST call return Invoke-RestMethod @invokeRestMethodParams } |