Set-MSTGroupPolicyAssignment
Teams: Update a group policy assignment
#Requires -Version 5.1
[CmdletBinding()]
Param(
[Parameter(Mandatory = $true)]
[string]$GroupId,
[Parameter(Mandatory = $true)]
[ValidateSet('TeamsAppSetupPolicy','TeamsCallingPolicy','TeamsCallParkPolicy','TeamsChannelsPolicy','TeamsComplianceRecordingPolicy','TeamsEducationAssignmentsAppPolicy','TeamsMeetingBroadcastPolicy','TeamsMeetingPolicy','TeamsMessagingPolicy')]
[string]$PolicyType,
[string]$PolicyName,
[int]$Rank
)
Process {
try {
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'; 'GroupId' = $GroupId; 'PolicyType' = $PolicyType}
if (-not [System.String]::IsNullOrWhiteSpace($PolicyName)) {
$cmdArgs.Add('PolicyName', $PolicyName)
}
if ($PSBoundParameters.ContainsKey('Rank')) {
$cmdArgs.Add('Rank', $Rank)
}
$result = Set-CsGroupPolicyAssignment @cmdArgs | Select-Object *
if ($null -eq $result) {
Write-Output "Group policy assignment updated"
return
}
$result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format 'yyyy-MM-dd HH:mm:ss') -PassThru -Force
}
catch { throw }
}Object ID of the group
The type of the policy
The new policy name to assign
The new rank of the policy assignment