Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Connect-PSZoom. #71

Merged
merged 7 commits into from
Aug 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions Examples/Get-ZoomInactiveUsers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ Default is 6 months from current day.
.PARAMETER To
The end date in 'yyyy-MM-dd' format. Default is the current date.

.PARAMETER ApiKey
The Api Key.

.PARAMETER ApiSecret
The Api Secret.

.OUTPUTS

.LINK
Expand Down
154 changes: 63 additions & 91 deletions Examples/New-CompanyZoomUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ with a single host and cannot be modified for these accounts.
If the value is set to `true`, the meeting passcode will be encrypted and included in the join meeting link to allow
participants to join with just one click without having to enter the passcode.

.PARAMETER ApiKey
The API key.

.PARAMETER ApiSecret
THe API secret.

.OUTPUTS
No output. Can use Passthru switch to pass UserId to output.

Expand Down Expand Up @@ -225,17 +219,7 @@ function New-CompanyZoomUser {

[Parameter(ValueFromPipelineByPropertyName = $True)]
[Alias('embed_password_in_join_link')]
[bool]$EmbedPasswordInJoinLink,

[Parameter(ParameterSetName = 'AdAccount')]
[Parameter(ParameterSetName = 'Manual')]
[ValidateNotNullOrEmpty()]
[string]$ApiKey,

[Parameter(ParameterSetName = 'AdAccount')]
[Parameter(ParameterSetName = 'Manual')]
[ValidateNotNullOrEmpty()]
[string]$ApiSecret
[bool]$EmbedPasswordInJoinLink
)

process {
Expand Down Expand Up @@ -281,101 +265,89 @@ function New-CompanyZoomUser {
'OfficeeName3' { 'Office 3' }
}

$GroupID = ((Get-ZoomGroups) | where-object {$_ -match "$OfficeLocation"}).id
$GroupID = ((Get-ZoomGroups) | where-object { $_ -match "$OfficeLocation" }).id

$params.Add('GroupId', $GroupId)
}

if ($ApiKey) {
$params.Add('ApiKey', $ApiKey)
}

if ($ApiKey) {
$params.Add('ApiSecret', $ApiSecret)
}

New-CompanyZoomUser @params
} elseif ($PSCmdlet.ParameterSetName -eq 'Manual') {
$creds = @{
ApiKey = 'ApiKey'
ApiSecret = 'ApiSecret'
}

if (Get-ZoomUser $Email -ErrorAction SilentlyContinue) {
throw "User already exists in Zoom."
New-CompanyZoomUser @params
}
elseif ($PSCmdlet.ParameterSetName -eq 'Manual') {
if (Get-ZoomUser $Email -ErrorAction SilentlyContinue) {
throw "User already exists in Zoom."
}

#Create new user
$defaultNewUserParams = @{
Action = $Action
Type = $Type
Email = $Email
}
#Create new user
$defaultNewUserParams = @{
Action = $Action
Type = $Type
Email = $Email
}

function Remove-NonPsBoundParameters {
param (
$Obj,
$Parameters = $PSBoundParameters
)
function Remove-NonPsBoundParameters {
param (
$Obj,
$Parameters = $PSBoundParameters
)

process {
$NewObj = @{ }
process {
$NewObj = @{ }

foreach ($Key in $Obj.Keys) {
if ($Parameters.ContainsKey($Obj.$Key) -or -not [string]::IsNullOrWhiteSpace($Obj.Key)) {
$Newobj.Add($Key, (get-variable $Obj.$Key).value)
foreach ($Key in $Obj.Keys) {
if ($Parameters.ContainsKey($Obj.$Key) -or -not [string]::IsNullOrWhiteSpace($Obj.Key)) {
$Newobj.Add($Key, (get-variable $Obj.$Key).value)
}
}
}

return $NewObj
return $NewObj
}
}
}

$newUserParams = @{
FirstName = 'FirstName'
LastName = 'LastName'
}
$newUserParams = @{
FirstName = 'FirstName'
LastName = 'LastName'
}

$newUserParams = Remove-NonPsBoundParameters($newUserParams)
$newUserParams = Remove-NonPsBoundParameters($newUserParams)

New-ZoomUser @defaultNewUserParams @newUserParams @creds
New-ZoomUser @defaultNewUserParams @newUserParams @creds

#Update parameters that cant be entered with new user
$updateParams = @{
UserId = 'Email'
HostKey = 'HostKey'
Pmi = 'Pmi'
Timezone = 'Timezone'
Language = 'Language'
Dept = 'Department'
VanityName = 'VanityName'
UsePmi = 'UsePmi'
}
#Update parameters that cant be entered with new user
$updateParams = @{
UserId = 'Email'
HostKey = 'HostKey'
Pmi = 'Pmi'
Timezone = 'Timezone'
Language = 'Language'
Dept = 'Department'
VanityName = 'VanityName'
UsePmi = 'UsePmi'
}

$updateParams = Remove-NonPsBoundParameters($updateParams)
$updateParams = Remove-NonPsBoundParameters($updateParams)

Update-ZoomUser @updateParams @creds
Update-ZoomUser @updateParams @creds

#Update Zoom User Meeting Settings
$updateSettingParams = @{
UserId = 'Email'
RequirePasswordForSchedulingNewMeetings = 'RequirePasswordForSchedulingNewMeetings'
RequirePasswordForPmiMeetings = 'RequirePasswordForPmiMeetings'
EmbedPasswordInJoinLink = 'EmbedPasswordInJoinLink'
}
#Update Zoom User Meeting Settings
$updateSettingParams = @{
UserId = 'Email'
RequirePasswordForSchedulingNewMeetings = 'RequirePasswordForSchedulingNewMeetings'
RequirePasswordForPmiMeetings = 'RequirePasswordForPmiMeetings'
EmbedPasswordInJoinLink = 'EmbedPasswordInJoinLink'
}

$updateSettingParams = Remove-NonPsBoundParameters($updateSettingParams)
$updateSettingParams = Remove-NonPsBoundParameters($updateSettingParams)

Update-ZoomUserSettings @updateSettingParams @creds
#Add user to group
if ($GroupId) {
Add-ZoomGroupMember -groupid $GroupId -MemberEmail $email @creds
}
Update-ZoomUserSettings @updateSettingParams @creds
#Add user to group
if ($GroupId) {
Add-ZoomGroupMember -groupid $GroupId -MemberEmail $email @creds
}

#Add scheduling permission on behalf of Admin
if ($SchedulingAssistant) {
Add-ZoomUserAssistants -UserId $Email -AssistantEmail $SchedulingAssistant @creds
#Add scheduling permission on behalf of Admin
if ($SchedulingAssistant) {
Add-ZoomUserAssistants -UserId $Email -AssistantEmail $SchedulingAssistant @creds
}
}
}
}
}
}
19 changes: 2 additions & 17 deletions Examples/Sync-ZoomUsersWithAdGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,7 @@ $UserExceptions = @(
$AdGroups = 'ZoomUsers'
$TransferAccount = 'AVAdmin@deathstar.com'

Sync-ZoomUsersWithAdGroup -AdGroups $AdGroups -UserExceptions $UserExceptions -TransferAccount $TransferAccount -ApiKey $ZoomApiKey -ApiSecret $ZoomApiKey -Confirm -Verbose

.PARAMETER ApiKey
The API key.

.PARAMETER ApiSecret
The API secret.
Sync-ZoomUsersWithAdGroup -AdGroups $AdGroups -UserExceptions $UserExceptions -TransferAccount $TransferAccount -Confirm -Verbose

#>

Expand All @@ -63,11 +57,7 @@ function Sync-ZoomUsersWithAdGroup() {

[switch]$Add = $False,

[switch]$Remove = $False,

[string]$ApiKey,

[string]$ApiSecret
[switch]$Remove = $False
)
begin {
if ($TransferAccount) {
Expand Down Expand Up @@ -114,11 +104,6 @@ function Sync-ZoomUsersWithAdGroup() {

$AdDiff = $AdZoomDiff | Where-Object -Property SideIndicator -eq '<=' | Select-Object -Property 'EmailAddress'

$params = @{
ApiKey = $ApiKey
ApiSecret = $ApiSecret
}

#Add users to Zoom that are in the $AdGroup and not in $UserExceptions.
if ($Add) {
Write-Verbose "Adding missing users that are in $AdGroup to Zoom. Skipping users in UserExceptions."
Expand Down
4 changes: 2 additions & 2 deletions PSZoom/PSZoom.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# Version number of this module.

ModuleVersion = '1.16.0.0'
ModuleVersion = '2.0.0.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand All @@ -28,7 +28,7 @@
CompanyName = 'Unknown'

# Copyright statement for this module
Copyright = '(c) 2020 Joseph McEvoy. All rights reserved.'
Copyright = '(c) 2022 Joseph McEvoy. All rights reserved.'

# Description of the functionality provided by this module
Description = 'A collection of Powershell tools to interface with the Zoom Api.'
Expand Down
66 changes: 0 additions & 66 deletions PSZoom/Private/Get-ZoomApiCredentials.ps1

This file was deleted.