@@ -6,16 +6,19 @@ Sync Zoom users with AD.
66Get all enabled users from AD and create a Zoom account if they don't have one. Remove disabled AD users from Zoom.
77#>
88[CmdletBinding (SupportsShouldProcess = $True )]
9- Param ()
9+ Param (
10+ [Parameter (Mandatory = $false )]
11+ [switch ]$UpdatePictureFromAD
12+ )
1013
1114Import-Module C:\powershell- scripts\Zoom\Zoom.psm1 - Force
1215Import-Module ActiveDirectory
1316
1417# Get all the enabled users
1518$EnabledFilter = { (Enabled -eq ' True' ) }
1619$SearchBase = ' OU=Users,DC=Company,DC=LOCAL'
17- $ADUsers = Get-ADUser - SearchBase $SearchBase - Filter $EnabledFilter - Properties telephoneNumber, thumbnailPhoto, mobile |
18- Where-Object { $_.distinguishedName -notlike ' *OU=Disabled*' }
20+ $ADUsers = Get-ADUser - SearchBase $SearchBase - Filter $EnabledFilter - Properties mail , telephoneNumber, thumbnailPhoto, mobile |
21+ Where-Object { $_.distinguishedName -notlike ' *OU=Disabled*' }
1922
2023$DefaultGroup = Get-ZoomGroup - Name Default | Select-Object - ExpandProperty group_id
2124
@@ -30,9 +33,9 @@ foreach ($User in $ADUsers) {
3033 }
3134
3235 # Pre-provision Zoom accounts for all selected AD users that don't already exist
33- if ($ZoomUsers.email -notcontains $User.UserPrincipalName ) {
36+ if ($ZoomUsers.email -notcontains $User.mail ) {
3437 $Params = @ {
35- Email = $User.UserPrincipalName
38+ Email = $User.mail
3639 FirstName = $User.GivenName
3740 LastName = $User.Surname
3841 License = ' Pro'
@@ -42,14 +45,14 @@ foreach ($User in $ADUsers) {
4245 if ($ZoomUsers.pmi -notcontains $PhoneNumber ) {
4346 $Params.Add (' Pmi' , $PhoneNumber )
4447 } else {
45- Write-Warning " Unable to set Pmi for $ ( $User.UserPrincipalName ) , $PhoneNumber already exists."
48+ Write-Warning " Unable to set Pmi for $ ( $User.mail ) , $PhoneNumber already exists."
4649 }
4750 }
4851
4952 New-ZoomSSOUser @Params
5053 # Update existing accounts with their AD info
5154 } else {
52- $ZoomUser = Get-ZoomUser - Email $User.UserPrincipalName
55+ $ZoomUser = Get-ZoomUser - Email $User.mail
5356
5457 $Params = @ { }
5558
@@ -65,12 +68,12 @@ foreach ($User in $ADUsers) {
6568 if ($ZoomUsers.pmi -notcontains $PhoneNumber ) {
6669 $Params.Add (' Pmi' , $PhoneNumber )
6770 } else {
68- Write-Warning " Unable to set Pmi for $ ( $User.UserPrincipalName ) , $PhoneNumber already exists."
71+ Write-Warning " Unable to set Pmi for $ ( $User.mail ) , $PhoneNumber already exists."
6972 }
7073 }
7174 }
72- if ($ZoomUser.vanity_url.Split (' /' )[-1 ] -ne $User.UserPrincipalName .Split (' @' )[0 ]) {
73- $Params.Add (' VanityName' , $User.UserPrincipalName .Split (' @' )[0 ])
75+ if ($ZoomUser.vanity_url.Split (' /' )[-1 ] -ne $User.mail .Split (' @' )[0 ]) {
76+ $Params.Add (' VanityName' , $User.mail .Split (' @' )[0 ])
7477 }
7578
7679 # Only update Zoom user properties if they have mismatches
@@ -83,13 +86,13 @@ foreach ($User in $ADUsers) {
8386 }
8487
8588 # Upload user photo if it exists
86- if ($User.thumbnailPhoto ) {
87- $ZoomUserId = Get-ZoomUser - Email $User.UserPrincipalName | Select-Object - ExpandProperty id
89+ if ($UpdatePictureFromAD -and $ User.thumbnailPhoto ) {
90+ $ZoomUserId = Get-ZoomUser - Email $User.mail | Select-Object - ExpandProperty id
8891 Set-ZoomUserPicture - Id $ZoomUserId - ByteArray $User.thumbnailPhoto
8992 }
9093}
9194
9295# Remove any Zoom accounts that don't have matching AD users
9396Get-ZoomUser - All | ForEach-Object {
94- if ($ADUsers.UserPrincipalName -notcontains $_.email ) { $_ | Remove-ZoomUser }
97+ if ($ADUsers.mail -notcontains $_.email ) { $_ | Remove-ZoomUser }
9598}
0 commit comments