Skip to content

Commit e29f956

Browse files
RodriguezRodriguez
authored andcommitted
Changed UPN to mail when dealing with AD user emails. Fixed typo. Param for pic add.
1 parent 8f4e463 commit e29f956

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

Zoom/Set-ZoomUserIntern.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $OtherGroupIds | ForEach-Object { $OtherGroupMembers.Add($_, (Get-ZoomGroupMembe
2424

2525
# Get Zoom intern users from AD group and set their Zoom license and group
2626
Get-ADGroupMember -Recursive -Identity 'Global - Interns' | Get-ADUser |
27-
Select-Object -ExpandProperty UserPrincipalName | ForEach-Object {
27+
Select-Object -ExpandProperty mail | ForEach-Object {
2828
try {
2929
$ZoomUser = Get-ZoomUser -Email $_
3030

Zoom/Set-ZoomUserInternational.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Import-Module ActiveDirectory
1111

1212
# Get Zoom international users from AD group
1313
$ADUsers = Get-ADGroupMember -Identity 'Zoom International Calling Accounts' |
14-
Get-ADUser | Select-Object -ExpandProperty UserPrincipalName
14+
Get-ADUser | Select-Object -ExpandProperty mail
1515

1616
$GroupInfo = @{}
1717
foreach ($Group in Get-ZoomGroup -All) {

Zoom/Update-ZoomADUser.ps1

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ Sync Zoom users with AD.
66
Get 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

1114
Import-Module C:\powershell-scripts\Zoom\Zoom.psm1 -Force
1215
Import-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
9396
Get-ZoomUser -All | ForEach-Object {
94-
if ($ADUsers.UserPrincipalName -notcontains $_.email) { $_ | Remove-ZoomUser }
97+
if ($ADUsers.mail -notcontains $_.email) { $_ | Remove-ZoomUser }
9598
}

Zoom/Zoom.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Set-ZoomApiAuth {
3030
Optional, sets a new Api secret.
3131
3232
.EXAMPLE
33-
Set-ZoomApi -Key 'mysupersecretapikey' -Secret 'mysupersecretapisecret
33+
Set-ZoomApi -Key 'mysupersecretapikey' -Secret 'mysupersecretapisecret'
3434
Sets your Zoom api key and secret to the files in the module directory.
3535
3636
.EXAMPLE

0 commit comments

Comments
 (0)