Functions/Remove-GSuiteGroup.ps1
<#
.SYNOPSIS This function removes one GSuite group. #> function Remove-GSuiteGroup { [CmdletBinding(PositionalBinding=$false)] [OutputType([Bool])] param ( # 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/$($primaryEmailAddress)" Method = "DELETE" Headers = @{ Accept = "application/json" Authorization = "Bearer $($Global:GSuiteAccessTokensHashTable.Group)" } } # Invoke the REST call $response = Invoke-RestMethod @invokeRestMethodParams # If the removal is successful, $response will be an empty string if ("" -eq $response) { return $true } else { return $false } } |