Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
param(
#Teams Administrator UserName
[Parameter(Mandatory)]
[string]
$Username,
#CSV File Path
[Parameter(Mandatory)]
[string]
$Path
)
$InformationPreference = 'Continue'
Write-Information -MessageData "Obtaining Module, please connect when prompted..."
Import-Module "C:\\Program Files\\Common Files\\Skype for Business Online\\Modules\\SkypeOnlineConnector\\SkypeOnlineConnector.psd1"
$Session = New-CsOnlineSession -UserName:$Username
Import-PSSession -Session:$Session -AllowClobber
@($(Import-csv -Path:"$PSScriptRoot\$Path")).ForEach( {
$csv = $PSItem
$userPrincipalName = $csv.userPrincipalName
Write-Information -MessageData:"Applying $($csv.DisplayName) Policies..."
#"TeamsMeetingPolicy",
Grant-CsTeamsMeetingPolicy -PolicyName $($csv.TeamsMeetingPolicy) -Identity $userPrincipalName
#"TeamsMessgingPolicy",
Grant-CsTeamsMessagingPolicy -PolicyName $($csv.TeamsMessagingPolicy) -Identity $userPrincipalName
#"TeamsMeetingBroadcastPolicy",
Grant-CsTeamsMeetingBroadcastPolicy -PolicyName $($csv.TeamsMeetingBroadcastPolicy) -Identity $userPrincipalName
#"TeamsAppPermissionPolicy",
Grant-CsTeamsAppPermissionPolicy -PolicyName $($csv.TeamsAppPermissionPolicy) -Identity $userPrincipalName
#"TeamsAppSetupPolicy",
Grant-CsTeamsAppSetupPolicy -PolicyName $($csv.TeamsAppSetupPolicy) -Identity $userPrincipalName
#"TeamsCallParkPolicy",
Grant-CsTeamsCallParkPolicy -PolicyName $($csv.TeamsCallParkPolicy) -Identity $userPrincipalName
#"TeamsCallingPolicy",
Grant-CsTeamsCallingPolicy -PolicyName $($csv.TeamsCallingPolicy) -Identity $userPrincipalName
#"CallerIDPolicy
Grant-CsCallingLineIdentity -PolicyName $($csv.CallerIdPolicy) -Identity $userPrincipalName
#"TeamsChannelsPolicy",
Grant-CsTeamsChannelsPolicy -PolicyName $($csv.TeamsChannelsPolicy) -Identity $userPrincipalName
#"TeamsEmergencyCallingPolicy",
Grant-CsTeamsEmergencyCallingPolicy -PolicyName $($csv.TeamsEmergencyCallingPolicy) -Identity $userPrincipalName
#"TeamsEmergencyCallRoutingPolicy",
Grant-CsTeamsEmergencyCallRoutingPolicy -PolicyName $($csv.TeamsEmergencyCallRoutingPolicy) -Identity $userPrincipalName
#"TenantDialPlan",
Grant-CsTenantDialPlan -PolicyName $($csv.TenantDialPlan) -Identity $userPrincipalName
#"TeamsUpgradePolicy"
Grant-CsTeamsUpgradePolicy -PolicyName $($csv.TeamsUpgradePolicy) -Identity $userPrincipalName
if ($Session.State -ne "Opened") {
Write-Warning "Session state closed, please reauthenticate"
Remove-PSSession -Session:$Session
$Session = New-CsOnlineSession -UserName:$Username
Import-PSSession -Session:$Session -AllowClobber
}
})
Write-Information "Complete"
Remove-PSSession -Session:$Session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment