Skip to content

Instantly share code, notes, and snippets.

@pmatthews05
Last active March 29, 2020 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmatthews05/4ef20344df45f023a88821891417b901 to your computer and use it in GitHub Desktop.
Save pmatthews05/4ef20344df45f023a88821891417b901 to your computer and use it in GitHub Desktop.
param(
[Parameter(Mandatory)]
[string]
$UserNameToSetPolicy,
[Parameter(Mandatory)]
[string]
$PolicyName
)
Import-Module "C:\\Program Files\\Common Files\\Skype for Business Online\\Modules\\SkypeOnlineConnector\\SkypeOnlineConnector.psd1"
$Session = New-CsOnlineSession
Import-PSSession -Session:$Session -AllowClobber
if (-not $(Get-CsTeamsMessagingPolicy -Identity:$PolicyName -ErrorAction:SilentlyContinue)){
Write-warning "Unable to find Policy $PolicyName"
return
}
else{
Write-Information "Granting Message Policy $PolicyName for user $UserNameToSetPolicy..."
Grant-CsTeamsMessagingPolicy -PolicyName $PolicyName -Identity $UserNameToSetPolicy
}
Remove-PSSession -Session:$session
write-Information "Done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment