@@ -75,12 +75,6 @@ with a single host and cannot be modified for these accounts.
7575If the value is set to `true`, the meeting passcode will be encrypted and included in the join meeting link to allow
7676participants to join with just one click without having to enter the passcode.
7777
78- . PARAMETER ApiKey
79- The API key.
80-
81- . PARAMETER ApiSecret
82- THe API secret.
83-
8478. OUTPUTS
8579No output. Can use Passthru switch to pass UserId to output.
8680
@@ -225,17 +219,7 @@ function New-CompanyZoomUser {
225219
226220 [Parameter (ValueFromPipelineByPropertyName = $True )]
227221 [Alias (' embed_password_in_join_link' )]
228- [bool ]$EmbedPasswordInJoinLink ,
229-
230- [Parameter (ParameterSetName = ' AdAccount' )]
231- [Parameter (ParameterSetName = ' Manual' )]
232- [ValidateNotNullOrEmpty ()]
233- [string ]$ApiKey ,
234-
235- [Parameter (ParameterSetName = ' AdAccount' )]
236- [Parameter (ParameterSetName = ' Manual' )]
237- [ValidateNotNullOrEmpty ()]
238- [string ]$ApiSecret
222+ [bool ]$EmbedPasswordInJoinLink
239223 )
240224
241225 process {
@@ -281,101 +265,89 @@ function New-CompanyZoomUser {
281265 ' OfficeeName3' { ' Office 3' }
282266 }
283267
284- $GroupID = ((Get-ZoomGroups ) | where-object {$_ -match " $OfficeLocation " }).id
268+ $GroupID = ((Get-ZoomGroups ) | where-object { $_ -match " $OfficeLocation " }).id
285269
286270 $params.Add (' GroupId' , $GroupId )
287- }
288-
289- if ($ApiKey ) {
290- $params.Add (' ApiKey' , $ApiKey )
291- }
292-
293- if ($ApiKey ) {
294- $params.Add (' ApiSecret' , $ApiSecret )
295- }
296271
297- New-CompanyZoomUser @params
298- } elseif ($PSCmdlet.ParameterSetName -eq ' Manual' ) {
299- $creds = @ {
300- ApiKey = ' ApiKey'
301- ApiSecret = ' ApiSecret'
302- }
303-
304- if (Get-ZoomUser $Email - ErrorAction SilentlyContinue) {
305- throw " User already exists in Zoom."
272+ New-CompanyZoomUser @params
306273 }
274+ elseif ($PSCmdlet.ParameterSetName -eq ' Manual' ) {
275+ if (Get-ZoomUser $Email - ErrorAction SilentlyContinue) {
276+ throw " User already exists in Zoom."
277+ }
307278
308- # Create new user
309- $defaultNewUserParams = @ {
310- Action = $Action
311- Type = $Type
312- Email = $Email
313- }
279+ # Create new user
280+ $defaultNewUserParams = @ {
281+ Action = $Action
282+ Type = $Type
283+ Email = $Email
284+ }
314285
315- function Remove-NonPsBoundParameters {
316- param (
317- $Obj ,
318- $Parameters = $PSBoundParameters
319- )
286+ function Remove-NonPsBoundParameters {
287+ param (
288+ $Obj ,
289+ $Parameters = $PSBoundParameters
290+ )
320291
321- process {
322- $NewObj = @ { }
292+ process {
293+ $NewObj = @ { }
323294
324- foreach ($Key in $Obj.Keys ) {
325- if ($Parameters.ContainsKey ($Obj .$Key ) -or -not [string ]::IsNullOrWhiteSpace($Obj.Key )) {
326- $Newobj.Add ($Key , (get-variable $Obj .$Key ).value)
295+ foreach ($Key in $Obj.Keys ) {
296+ if ($Parameters.ContainsKey ($Obj .$Key ) -or -not [string ]::IsNullOrWhiteSpace($Obj.Key )) {
297+ $Newobj.Add ($Key , (get-variable $Obj .$Key ).value)
298+ }
327299 }
328- }
329300
330- return $NewObj
301+ return $NewObj
302+ }
331303 }
332- }
333304
334- $newUserParams = @ {
335- FirstName = ' FirstName'
336- LastName = ' LastName'
337- }
305+ $newUserParams = @ {
306+ FirstName = ' FirstName'
307+ LastName = ' LastName'
308+ }
338309
339- $newUserParams = Remove-NonPsBoundParameters ($newUserParams )
310+ $newUserParams = Remove-NonPsBoundParameters ($newUserParams )
340311
341- New-ZoomUser @defaultNewUserParams @newUserParams @creds
312+ New-ZoomUser @defaultNewUserParams @newUserParams @creds
342313
343- # Update parameters that cant be entered with new user
344- $updateParams = @ {
345- UserId = ' Email'
346- HostKey = ' HostKey'
347- Pmi = ' Pmi'
348- Timezone = ' Timezone'
349- Language = ' Language'
350- Dept = ' Department'
351- VanityName = ' VanityName'
352- UsePmi = ' UsePmi'
353- }
314+ # Update parameters that cant be entered with new user
315+ $updateParams = @ {
316+ UserId = ' Email'
317+ HostKey = ' HostKey'
318+ Pmi = ' Pmi'
319+ Timezone = ' Timezone'
320+ Language = ' Language'
321+ Dept = ' Department'
322+ VanityName = ' VanityName'
323+ UsePmi = ' UsePmi'
324+ }
354325
355- $updateParams = Remove-NonPsBoundParameters ($updateParams )
326+ $updateParams = Remove-NonPsBoundParameters ($updateParams )
356327
357- Update-ZoomUser @updateParams @creds
328+ Update-ZoomUser @updateParams @creds
358329
359- # Update Zoom User Meeting Settings
360- $updateSettingParams = @ {
361- UserId = ' Email'
362- RequirePasswordForSchedulingNewMeetings = ' RequirePasswordForSchedulingNewMeetings'
363- RequirePasswordForPmiMeetings = ' RequirePasswordForPmiMeetings'
364- EmbedPasswordInJoinLink = ' EmbedPasswordInJoinLink'
365- }
330+ # Update Zoom User Meeting Settings
331+ $updateSettingParams = @ {
332+ UserId = ' Email'
333+ RequirePasswordForSchedulingNewMeetings = ' RequirePasswordForSchedulingNewMeetings'
334+ RequirePasswordForPmiMeetings = ' RequirePasswordForPmiMeetings'
335+ EmbedPasswordInJoinLink = ' EmbedPasswordInJoinLink'
336+ }
366337
367- $updateSettingParams = Remove-NonPsBoundParameters ($updateSettingParams )
338+ $updateSettingParams = Remove-NonPsBoundParameters ($updateSettingParams )
368339
369- Update-ZoomUserSettings @updateSettingParams @creds
370- # Add user to group
371- if ($GroupId ) {
372- Add-ZoomGroupMember - groupid $GroupId - MemberEmail $email @creds
373- }
340+ Update-ZoomUserSettings @updateSettingParams @creds
341+ # Add user to group
342+ if ($GroupId ) {
343+ Add-ZoomGroupMember - groupid $GroupId - MemberEmail $email @creds
344+ }
374345
375- # Add scheduling permission on behalf of Admin
376- if ($SchedulingAssistant ) {
377- Add-ZoomUserAssistants - UserId $Email - AssistantEmail $SchedulingAssistant @creds
346+ # Add scheduling permission on behalf of Admin
347+ if ($SchedulingAssistant ) {
348+ Add-ZoomUserAssistants - UserId $Email - AssistantEmail $SchedulingAssistant @creds
349+ }
378350 }
379351 }
380352 }
381- }
353+ }
0 commit comments