From 6039c0f122ecc85cd5e567101bfda2bbf21ef8dd Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Tue, 10 May 2022 15:42:55 -0600 Subject: [PATCH 01/23] Merge 1.21.0 & Backup-JCOrg changes --- .circleci/workflows.yml | 4 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- .../Utilities/Backup-JCOrganization.ps1 | 101 +++++++++++++++++- PowerShell/ModuleBanner.md | 2 +- PowerShell/ModuleChangelog.md | 23 +++- 5 files changed, 124 insertions(+), 8 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index fd4ddf8a4..8f97ecc25 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -32,7 +32,7 @@ parameters: description: 'Release Type. Accepted values [ Major, Minor, Patch ]' type: enum enum: ["Major", "Minor", "Patch"] - default: "Minor" + default: "Patch" RequiredModulesRepo: description: 'PowerShell Repository for JumpCloud SDKs' type: enum @@ -45,7 +45,7 @@ parameters: PublishToPSGallery: description: 'When `true` and when run against Master branch, this workflow will publish the latest code to PSGallery' type: boolean - default: true + default: false ManualModuleVersion: description: 'When `true` the pipeline will use the Module Version specified in JumpCloud Module JumpCloud.psd1 file' type: boolean diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 358d701d4..1e54fc5d2 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.21.0' +ModuleVersion = '1.21.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 b/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 index d45fd2dbe..b07ce527b 100644 --- a/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 +++ b/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 @@ -220,7 +220,7 @@ Function Backup-JCOrganization $AssociationBaseName = "Association-{0}To{1}" -f $SourceTypeMap.Key, $TargetTypeMap.Key $AssociationFileName = "{0}.{1}" -f $AssociationBaseName, $Format $AssociationFullName = "{0}/{1}" -f $TempPath, $AssociationFileName - $AssociationJobs += Start-Job -ScriptBlock:( { Param ($SourceTypeMap, $TargetTypeMap, $BackupFile, $AssociationBaseName, $AssociationFileName, $AssociationFullName, $Format, $Debug); + $AssociationJobs += Start-Job -ScriptBlock:( { Param ($SourceTypeMap, $TargetTypeMap, $BackupFile, $AssociationBaseName, $AssociationFileName, $AssociationFullName, $Format, $Settings, $Debug); $AssociationResults = @() # Get content from the file $BackupRecords = If ($Format -eq 'json') @@ -288,6 +288,103 @@ Function Backup-JCOrganization $AssociationResults += $AssociationResult } } + ElseIf (($SourceTypeMap.Value.Name -eq 'command' -and $TargetTypeMap.Value.Name -eq 'system' -and $Settings.ROLE -eq 'Read Only') -or ($SourceTypeMap.Value.Name -eq 'command' -and $TargetTypeMap.Value.Name -eq 'system_group' -and $Settings.ROLE -eq 'Read Only')) + { + # Note on SA-2014 read only cases, this is temporary and should be addressed in the API but this is proving difficult, these cases are only necessary since the association endpoints on systems->commands/softwareapps is disabled for readonly users + $Command = 'Get-JcSdk{0}Traverse{2} -{0}Id:("{1}")' -f $SourceTypeMap.Key, $BackupRecord.id, (Get-Culture).TextInfo.ToTitleCase($TargetTypeMap.Value.Name) + If ($PSBoundParameters.Debug) { Write-Host ("DEBUG: Running: $Command") -ForegroundColor:('Yellow') } + $AssociationResult = Invoke-Expression -Command:($Command) + If (-not [System.String]::IsNullOrEmpty($AssociationResult)) + { + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. + $AssociationResult.Paths | ForEach-Object { + $_ | ForEach-Object { + If ([System.String]::IsNullOrEmpty($_.FromId)) + { + $_.FromId = $BackupRecord.id + } + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. + If ([System.String]::IsNullOrEmpty($_.FromType)) + { + $_.FromType = $SourceTypeMap.Value.Name + } + } + } + $AssociationResults += $AssociationResult + } + } + ElseIf (($SourceTypeMap.Value.Name -eq 'system' -and $TargetTypeMap.Value.Name -eq 'command' -and $Global:JCSettings.ROLE -eq 'Read Only') -or ($SourceTypeMap.Value.Name -eq 'system_group' -and $TargetTypeMap.Value.Name -eq 'command' -and $Global:JCSettings.ROLE -eq 'Read Only')) + { + $Command = 'Get-JcSdk{0}Traverse{2} -{0}Id:("{1}")' -f $SourceTypeMap.Key, $BackupRecord.id, (Get-Culture).TextInfo.ToTitleCase($TargetTypeMap.Value.Name) + If ($PSBoundParameters.Debug) { Write-Host ("DEBUG: Running: $Command") -ForegroundColor:('Yellow') } + $AssociationResult = Invoke-Expression -Command:($Command) + If (-not [System.String]::IsNullOrEmpty($AssociationResult)) + { + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. + $AssociationResult.Paths | ForEach-Object { + $_ | ForEach-Object { + If ([System.String]::IsNullOrEmpty($_.FromId)) + { + $_.FromId = $BackupRecord.id + } + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. + If ([System.String]::IsNullOrEmpty($_.FromType)) + { + $_.FromType = $SourceTypeMap.Value.Name + } + } + } + $AssociationResults += $AssociationResult + } + } + ElseIf (($SourceTypeMap.Value.Name -eq 'SoftwareApp' -and $TargetTypeMap.Value.Name -eq 'system' -and $Global:JCSettings.ROLE -eq 'Read Only') -or ($SourceTypeMap.Value.Name -eq 'SoftwareApp' -and $TargetTypeMap.Value.Name -eq 'system_group' -and $Global:JCSettings.ROLE -eq 'Read Only')) + { + $Command = 'Get-JcSdk{0}Traverse{2} -{0}Id:("{1}")' -f $SourceTypeMap.Key, $BackupRecord.id, (Get-Culture).TextInfo.ToTitleCase($TargetTypeMap.Value.Name) + If ($PSBoundParameters.Debug) { Write-Host ("DEBUG: Running: $Command") -ForegroundColor:('Yellow') } + $AssociationResult = Invoke-Expression -Command:($Command) + If (-not [System.String]::IsNullOrEmpty($AssociationResult)) + { + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. + $AssociationResult.Paths | ForEach-Object { + $_ | ForEach-Object { + If ([System.String]::IsNullOrEmpty($_.FromId)) + { + $_.FromId = $BackupRecord.id + } + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. + If ([System.String]::IsNullOrEmpty($_.FromType)) + { + $_.FromType = $SourceTypeMap.Value.Name + } + } + } + $AssociationResults += $AssociationResult + } + } + ElseIf (($SourceTypeMap.Value.Name -eq 'system' -and $TargetTypeMap.Value.Name -eq 'SoftwareApp' -and $Global:JCSettings.ROLE -eq 'Read Only') -or ($SourceTypeMap.Value.Name -eq 'system_group' -and $TargetTypeMap.Value.Name -eq 'SoftwareApp' -and $Global:JCSettings.ROLE -eq 'Read Only')) + { + $Command = 'Get-JcSdk{0}Traverse{2} -{0}Id:("{1}")' -f $SourceTypeMap.Key, $BackupRecord.id, (Get-Culture).TextInfo.ToTitleCase($TargetTypeMap.Value.Name) + If ($PSBoundParameters.Debug) { Write-Host ("DEBUG: Running: $Command") -ForegroundColor:('Yellow') } + $AssociationResult = Invoke-Expression -Command:($Command) + If (-not [System.String]::IsNullOrEmpty($AssociationResult)) + { + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. + $AssociationResult.Paths | ForEach-Object { + $_ | ForEach-Object { + If ([System.String]::IsNullOrEmpty($_.FromId)) + { + $_.FromId = $BackupRecord.id + } + # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. + If ([System.String]::IsNullOrEmpty($_.FromType)) + { + $_.FromType = $SourceTypeMap.Value.Name + } + } + } + $AssociationResults += $AssociationResult + } + } Else { $Command = 'Get-JcSdk{0}Association -{1}Id:("{2}") -Targets:("{3}")' -f $SourceTypeMap.Key, $SourceTypeMap.Key.Replace('UserGroup', 'Group').Replace('SystemGroup', 'Group'), $BackupRecord.id, $TargetTypeMap.Value.Name @@ -342,7 +439,7 @@ Function Backup-JCOrganization # Build hash to return data Return @{$AssociationBaseName = $AssociationResults } } - }) -ArgumentList:($SourceTypeMap, $TargetTypeMap, $BackupFile, $AssociationBaseName, $AssociationFileName, $AssociationFullName, $Format, $PSBoundParameters.Debug) + }) -ArgumentList:($SourceTypeMap, $TargetTypeMap, $BackupFile, $AssociationBaseName, $AssociationFileName, $AssociationFullName, $Format, $global:JCSettings, $PSBoundParameters.Debug) } } } diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index b169fabdc..91782224e 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,7 +1,7 @@ #### Latest Version ``` -1.21.0 +1.21.1 ``` #### Banner Current diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index c0116b107..d4afcd323 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,9 +1,29 @@ -## 1.21.0 +## 1.21.1 Release Date: May 3, 2022 #### RELEASE NOTES +``` +This patch release address a bug with Backup-JCOrganization and read-only API Keys +``` +#### IMPROVEMENTS: + +N/A +#### FEATURES: + +N/A + +#### BUG FIXES: + +SA-2014 - Backup-JCOrganization throws a forbidden error message when run with a read-only API Key. + +## 1.21.0 + +Release Date: May 11, 2022 + +#### RELEASE NOTES + ``` This release includes an update to Update-JCModule intended to help updating future fersions of the PowerShell SDK @@ -12,7 +32,6 @@ This release includes an update to Update-JCModule intended to help updating fut * Update-JCModule specifically targets which version of the new SDK to install and uninstall. -``` #### FEATURES: * This release adds the -recoveryemail parameter to Set, Get, New-JCUser From 2c6a9cd946ba38b1df63473fa26a649108b073f6 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Wed, 11 May 2022 15:22:19 -0600 Subject: [PATCH 02/23] formatting for read-only admins --- .../Utilities/Backup-JCOrganization.ps1 | 41 ++++--------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 b/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 index b07ce527b..4d000d17f 100644 --- a/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 +++ b/PowerShell/JumpCloud Module/Public/Utilities/Backup-JCOrganization.ps1 @@ -299,18 +299,11 @@ Function Backup-JCOrganization # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. $AssociationResult.Paths | ForEach-Object { $_ | ForEach-Object { - If ([System.String]::IsNullOrEmpty($_.FromId)) - { - $_.FromId = $BackupRecord.id - } - # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. - If ([System.String]::IsNullOrEmpty($_.FromType)) - { - $_.FromType = $SourceTypeMap.Value.Name + if ($_.FromType -eq $SourceTypeMap.Value.Name -and $_.ToType -eq $TargetTypeMap.Value.Name){ + $AssociationResults += $_ } } } - $AssociationResults += $AssociationResult } } ElseIf (($SourceTypeMap.Value.Name -eq 'system' -and $TargetTypeMap.Value.Name -eq 'command' -and $Global:JCSettings.ROLE -eq 'Read Only') -or ($SourceTypeMap.Value.Name -eq 'system_group' -and $TargetTypeMap.Value.Name -eq 'command' -and $Global:JCSettings.ROLE -eq 'Read Only')) @@ -323,18 +316,12 @@ Function Backup-JCOrganization # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. $AssociationResult.Paths | ForEach-Object { $_ | ForEach-Object { - If ([System.String]::IsNullOrEmpty($_.FromId)) - { - $_.FromId = $BackupRecord.id - } - # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. - If ([System.String]::IsNullOrEmpty($_.FromType)) + if ($_.FromType -eq $SourceTypeMap.Value.Name -and $_.ToType -eq $TargetTypeMap.Value.Name) { - $_.FromType = $SourceTypeMap.Value.Name + $AssociationResults += $_ } } } - $AssociationResults += $AssociationResult } } ElseIf (($SourceTypeMap.Value.Name -eq 'SoftwareApp' -and $TargetTypeMap.Value.Name -eq 'system' -and $Global:JCSettings.ROLE -eq 'Read Only') -or ($SourceTypeMap.Value.Name -eq 'SoftwareApp' -and $TargetTypeMap.Value.Name -eq 'system_group' -and $Global:JCSettings.ROLE -eq 'Read Only')) @@ -347,18 +334,12 @@ Function Backup-JCOrganization # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. $AssociationResult.Paths | ForEach-Object { $_ | ForEach-Object { - If ([System.String]::IsNullOrEmpty($_.FromId)) - { - $_.FromId = $BackupRecord.id - } - # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. - If ([System.String]::IsNullOrEmpty($_.FromType)) + if ($_.FromType -eq $SourceTypeMap.Value.Name -and $_.ToType -eq $TargetTypeMap.Value.Name) { - $_.FromType = $SourceTypeMap.Value.Name + $AssociationResults += $_ } } } - $AssociationResults += $AssociationResult } } ElseIf (($SourceTypeMap.Value.Name -eq 'system' -and $TargetTypeMap.Value.Name -eq 'SoftwareApp' -and $Global:JCSettings.ROLE -eq 'Read Only') -or ($SourceTypeMap.Value.Name -eq 'system_group' -and $TargetTypeMap.Value.Name -eq 'SoftwareApp' -and $Global:JCSettings.ROLE -eq 'Read Only')) @@ -371,18 +352,12 @@ Function Backup-JCOrganization # The direct association/"Get-JcSdk*Membership" endpoints return null for FromId. So manually populate them here. $AssociationResult.Paths | ForEach-Object { $_ | ForEach-Object { - If ([System.String]::IsNullOrEmpty($_.FromId)) - { - $_.FromId = $BackupRecord.id - } - # The direct association/"Get-JcSdk*Membership" endpoints return null for FromType. So manually populate them here. - If ([System.String]::IsNullOrEmpty($_.FromType)) + if ($_.FromType -eq $SourceTypeMap.Value.Name -and $_.ToType -eq $TargetTypeMap.Value.Name) { - $_.FromType = $SourceTypeMap.Value.Name + $AssociationResults += $_ } } } - $AssociationResults += $AssociationResult } } Else From 1b5699d7844ce5395c9caca5f0630d872ed9108a Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Wed, 11 May 2022 21:36:05 +0000 Subject: [PATCH 03/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 3611f0ae2..41bd80135 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 1.21.0 +Help Version: 1.21.1 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 1e54fc5d2..3675b292e 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 5/10/2022 +# Generated on: 5/11/2022 # @{ From f3d14ff4e97d1ae65f3421e4b35c3a0390c76fdf Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Thu, 12 May 2022 17:58:04 +0000 Subject: [PATCH 04/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 3675b292e..770401f2a 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 5/11/2022 +# Generated on: 5/12/2022 # @{ From 077f5864f4cd51ced693fa7fc0f5afa1f0977e65 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Fri, 13 May 2022 09:12:42 -0700 Subject: [PATCH 05/23] Email search to manager field --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- .../Public/Users/Get-JCUser.ps1 | 52 ++++++++++++++----- .../Public/Users/New-JCUser.ps1 | 26 ++++++++++ .../Public/Users/Set-JCUser.ps1 | 29 +++++++++++ PowerShell/ModuleBanner.md | 6 +-- PowerShell/ModuleChangelog.md | 21 ++++++++ 6 files changed, 120 insertions(+), 16 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 358d701d4..4e51e70fd 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.21.0' +ModuleVersion = '1.22.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 402b8155e..cb381cf0e 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -323,7 +323,7 @@ Function Get-JCUser () $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actually a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ filter = @{ @@ -337,19 +337,47 @@ Function Get-JCUser () $managerValue = $managerResults.id } } - else { - # search the username in the search endpoint - $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + # Use class mailaddress to check if $param.value is email + elseif ([mailaddress]$param.Value) + { + # Search manager using email + $managerSearch = @{ + filter = @{ + or = @( + 'email:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue; this is a validated user id + $managerValue = $managerResults.id + if (!$managerValue){ + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id } + + } + else { + # search the username in the search endpoint + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } if ($managerValue) { # if an ID was validated ($Search.filter).GetEnumerator().add($param.Key, $managerValue) diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index 95b5af8a4..8e27f1f95 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -349,6 +349,32 @@ Function New-JCUser () $managerValue = $managerResults.id } } + # Use class mailaddress to check if $param.value is email + elseif ([mailaddress]$param.value) { + $managerSearch = @{ + filter = @{ + or = @( + 'email:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue; this is a validated user id + $managerValue = $managerResults.id + # if no value was returned, then assume the case this is actuallty a username and search + if (!$managerValue){ + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id + } + } else { # search the username in the search endpoint $managerSearch = @{ diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 7cea49152..f923b9603 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -629,6 +629,35 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerValue = $managerResults.id } } + # Use class mailaddress to check if $param.value is email + elseif([mailaddress]$param.value) # If value is email + { + Write-Debug "This is true" + # Search for manager using email + $managerSearch = @{ + filter = @{ + or = @( + 'email:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue; this is a validated user id + $managerValue = $managerResults.id + # if no value was returned, then assume the case this is actuallty a username and search + if (!$managerValue){ + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id + } + } else { # search the username in the search endpoint $managerSearch = @{ diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index b169fabdc..e26a5a2f5 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,17 @@ #### Latest Version ``` -1.21.0 +1.22.0 ``` #### Banner Current ``` -New parameter -recoveryemail for Set, Get, New-JCUser +Added functionality for Set, Get, New-JCUser to Search by Email to Manager Field ``` #### Banner Old ``` -Get-JcUser, Set-JcUser and New-JcUser will soon be deprecating the -suspended parameter. Please use the -state paramater as a replacement. +New parameter -recoveryemail for Set, Get, New-JCUser ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index a10b1de35..32bcbbf3f 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,24 @@ +## 1.22.0 + +Release Date: May 13, 2022 + +#### RELEASE NOTES + +``` +This release includes an update to Set, Get, New-JCUser to add the use of Email to the Manager field + +``` +#### IMPROVEMENTS: + +* Set, Get, New-JCUser will validate email address value given to -manager + +#### FEATURES: + +* This release adds email search to manager field in Set, Get, New-JCUser + +#### BUG FIXES: + +N/A ## 1.21.0 Release Date: May 11, 2022 From de9ba0d1889f8cda38d7e0424c2629605442a109 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Fri, 13 May 2022 16:24:29 +0000 Subject: [PATCH 06/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 3611f0ae2..531849ba3 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 1.21.0 +Help Version: 1.22.0 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 4e51e70fd..19abb32ca 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 5/10/2022 +# Generated on: 5/13/2022 # @{ From cb233a4cc91f17509018deee0a85a8cafc8f32a5 Mon Sep 17 00:00:00 2001 From: Joe Workman Date: Fri, 13 May 2022 12:04:51 -0600 Subject: [PATCH 07/23] try catch email manager lookup + tests --- .../Public/Users/Get-JCUser.ps1 | 55 +++++---- .../Public/Users/New-JCUser.ps1 | 5 +- .../Public/Users/Set-JCUser.ps1 | 109 ++++++++++++++++-- .../Tests/Public/Users/Get-JCUser.tests.ps1 | 8 ++ .../Tests/Public/Users/New-JCUser.tests.ps1 | 7 ++ .../Tests/Public/Users/Set-JCUser.tests.ps1 | 16 +++ 6 files changed, 158 insertions(+), 42 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index cb381cf0e..5643d2bd1 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -337,36 +337,21 @@ Function Get-JCUser () $managerValue = $managerResults.id } } - # Use class mailaddress to check if $param.value is email - elseif ([mailaddress]$param.Value) - { - # Search manager using email - $managerSearch = @{ - filter = @{ - or = @( - 'email:$eq:' + $param.Value - ) - } - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue; this is a validated user id - $managerValue = $managerResults.id - if (!$managerValue){ - $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) - } - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id + # Use class mailaddress to check if $param.value is email + try { + $null = [mailaddress]$EmailAddress + # Search manager using email + $managerSearch = @{ + filter = @{ + or = @( + 'email:$eq:' + $param.Value + ) } - } - else { - # search the username in the search endpoint + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue; this is a validated user id + $managerValue = $managerResults.id + if (!$managerValue){ $managerSearch = @{ filter = @{ or = @( @@ -378,6 +363,20 @@ Function Get-JCUser () # Set managerValue from the matched username $managerValue = $managerResults.id } + } + catch { + # search the username in the search endpoint + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id + } if ($managerValue) { # if an ID was validated ($Search.filter).GetEnumerator().add($param.Key, $managerValue) diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index 8e27f1f95..08a3343f5 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -350,7 +350,8 @@ Function New-JCUser () } } # Use class mailaddress to check if $param.value is email - elseif ([mailaddress]$param.value) { + try { + $null = [mailaddress]$EmailAddress $managerSearch = @{ filter = @{ or = @( @@ -375,7 +376,7 @@ Function New-JCUser () $managerValue = $managerResults.id } } - else { + catch { # search the username in the search endpoint $managerSearch = @{ filter = @{ diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index f923b9603..9f57efd31 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -615,7 +615,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ filter = @{ @@ -630,8 +630,8 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline } } # Use class mailaddress to check if $param.value is email - elseif([mailaddress]$param.value) # If value is email - { + try { + $null = [mailaddress]$EmailAddress Write-Debug "This is true" # Search for manager using email $managerSearch = @{ @@ -644,7 +644,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ filter = @{ @@ -658,7 +658,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerValue = $managerResults.id } } - else { + catch { # search the username in the search endpoint $managerSearch = @{ filter = @{ @@ -800,8 +800,36 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerValue = $managerResults.id } } - else - { + # Use class mailaddress to check if $param.value is email + try { + $null = [mailaddress]$EmailAddress + Write-Debug "This is true" + # Search for manager using email + $managerSearch = @{ + filter = @{ + or = @( + 'email:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue; this is a validated user id + $managerValue = $managerResults.id + # if no value was returned, then assume the case this is actually a username and search + if (!$managerValue){ + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id + } + } + catch { # search the username in the search endpoint $managerSearch = @{ filter = @{ @@ -1009,7 +1037,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue) { $managerSearch = @{ @@ -1024,8 +1052,36 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerValue = $managerResults.id } } - else - { + # Use class mailaddress to check if $param.value is email + try { + $null = [mailaddress]$EmailAddress + Write-Debug "This is true" + # Search for manager using email + $managerSearch = @{ + filter = @{ + or = @( + 'email:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue; this is a validated user id + $managerValue = $managerResults.id + # if no value was returned, then assume the case this is actually a username and search + if (!$managerValue){ + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id + } + } + catch { # search the username in the search endpoint $managerSearch = @{ filter = @{ @@ -1179,7 +1235,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ filter = @{ @@ -1193,7 +1249,36 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerValue = $managerResults.id } } - else { + # Use class mailaddress to check if $param.value is email + try { + $null = [mailaddress]$EmailAddress + Write-Debug "This is true" + # Search for manager using email + $managerSearch = @{ + filter = @{ + or = @( + 'email:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue; this is a validated user id + $managerValue = $managerResults.id + # if no value was returned, then assume the case this is actually a username and search + if (!$managerValue){ + $managerSearch = @{ + filter = @{ + or = @( + 'username:$eq:' + $param.Value + ) + } + } + $managerResults = Search-JcSdkUser -Body:($managerSearch) + # Set managerValue from the matched username + $managerValue = $managerResults.id + } + } + catch { # search the username in the search endpoint $managerSearch = @{ filter = @{ diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 index dc24b044e..3707ee602 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 @@ -94,6 +94,14 @@ Describe -Tag:('JCUser') 'Get-JCUser 1.1' { $NewUser.manager | Should -Be $managerId Remove-JCUser -UserID $NewUser._id -force } + It "Searches a JumpCloud user by managerEmail" { + $managerEmail = $PesterParams_User1.email + $managerId = $PesterParams_User1.id + $NewUser = New-RandomUser -Domain DeleteMe | New-JCUser -manager $managerEmail + $NewUser = Get-JCUser -manager $managerEmail + $NewUser.manager | Should -Be $managerId + Remove-JCUser -UserID $NewUser._id -force + } It "Searches a JumpCloud user by state SUSPENDED" { $NewUser = New-RandomUser -Domain DeleteMe | New-JcUser -state "SUSPENDED" $SearchUser = Get-JCUser -state "SUSPENDED" | Select-Object -First 1 diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.tests.ps1 index eec086b62..d1b9802b5 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.tests.ps1 @@ -103,6 +103,13 @@ Describe -Tag:('JCUser') 'New-JCUser 1.0' { $NewUser.manager | Should -Be $managerID Remove-JCUser -UserID $NewUser._id -ByID -Force } + It "Creates a new User sets managerEmail" { + $managerEmail = $PesterParams_User1.email + $managerID = $PesterParams_User1.id + $NewUser = New-RandomUser -domain pleasedelete"PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser -manager $managerEmail + $NewUser.manager | Should -Be $managerID + Remove-JCUser -UserID $NewUser._id -ByID -Force + } It "Creates a new User sets alternateEmail" { $alternateEmail = "$((New-RandomString -NumberOfChars 6))ae@DeleteMe.com" $NewUser = New-RandomUser -domain pleasedelete"PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser -alternateEmail $alternateEmail diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 index 8c1b653a4..1ec815754 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 @@ -78,6 +78,14 @@ Describe -Tag:('JCUser') 'Set-JCUser 1.0' { Remove-JCUser -UserID $NewUser._id -force Remove-JCUser -UserID $ManagerUser._id -force } + It "Updates the managerUsername using email" { + $ManagerUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser + $NewUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser + $NewManager = Set-JCUser -Username $NewUser.Username -manager $ManagerUser.email + $NewManager.manager | Should -Be $ManagerUser.id + Remove-JCUser -UserID $NewUser._id -force + Remove-JCUser -UserID $ManagerUser._id -force + } It "Updates the managerUsername using -ByID and -UserID" { $ManagerUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser $NewUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser @@ -86,6 +94,14 @@ Describe -Tag:('JCUser') 'Set-JCUser 1.0' { Remove-JCUser -UserID $NewUser._id -force Remove-JCUser -UserID $ManagerUser._id -force } + It "Updates the managerEmail using -ByID and -UserID" { + $ManagerUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser + $NewUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser + $NewManager = Set-JCUser -ByID -UserID $NewUser._id -manager $ManagerUser.email + $NewManager.manager | Should -Be $ManagerUser.id + Remove-JCUser -UserID $NewUser._id -force + Remove-JCUser -UserID $ManagerUser._id -force + } It "Updates the managerId using -Username" { $ManagerUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser $ManagerId = $ManagerUser.id From b78eb63fdc0f5803cb18a2d8da5d88064b0cc2f3 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Mon, 16 May 2022 10:40:17 -0500 Subject: [PATCH 08/23] add new params --- .../Private/NestedFunctions/Get-JCResults.ps1 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCResults.ps1 b/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCResults.ps1 index a63b45c44..3207686c8 100644 --- a/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCResults.ps1 +++ b/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCResults.ps1 @@ -2,7 +2,10 @@ Function Get-JCResults { [CmdletBinding()] Param( - [Parameter(Mandatory = $true, HelpMessage = 'URL of Endpoint')][ValidateNotNullOrEmpty()]$URL + [Parameter(Mandatory = $true, HelpMessage = 'URL of Endpoint')][ValidateNotNullOrEmpty()]$URL, + [Parameter(Mandatory = $true, HelpMessage = 'Method of WebRequest')][ValidateNotNullOrEmpty()]$method, + [Parameter(Mandatory = $true, HelpMessage = 'Limit of WebRequest')][ValidateNotNullOrEmpty()]$limit, + [Parameter(Mandatory = $false, HelpMessage = 'Body of WebRequest, if required')]$body ) begin { $hdrs = @{ @@ -16,7 +19,7 @@ Function Get-JCResults } $resultsArray = @() $totalCount = 1 - $limit = 100 + $limit = [int]$limit $skip = 0 } process { @@ -29,11 +32,16 @@ Function Get-JCResults $passCounter = [math]::ceiling($totalCount/$limit) Write-Debug "number of passes: $passCounter" $resultsArray += $response.Content | ConvertFrom-Json - + for($i = 1; $i -lt $passCounter; $i++) { $skip += $limit $limitURL = $URL + "?limit=$limit&skip=$skip" - $response = Invoke-WebRequest -Method GET -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent) + if ($body){ + $response = Invoke-WebRequest -Method $method -Body $body -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent) + } + else { + $response = Invoke-WebRequest -Method $method -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent) + } $resultsArray += $response.Content | ConvertFrom-Json Write-Debug ("Pass: $i Amount: " + ($response.Content | ConvertFrom-Json).Count) } From d659066174f987afc436916fd6f5203d28835454 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Mon, 16 May 2022 10:40:32 -0500 Subject: [PATCH 09/23] update existing get-jcresults instances for new params --- .../Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 | 4 ++-- .../Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 b/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 index ad6b5d491..bad6d0761 100644 --- a/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 +++ b/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 @@ -57,7 +57,7 @@ Function Get-JCSystemGroupMember () Write-Debug "$Group_ID" $limitURL = "{0}/api/v2/Systemgroups/{1}/members" -f $JCUrlBasePath, $Group_ID - $rawResults = Get-JCResults -Url $limitURL + $rawResults = Get-JCResults -Url $limitURL -method "GET" -limit 100 foreach ($uid in $rawResults) { @@ -86,7 +86,7 @@ Function Get-JCSystemGroupMember () { $limitURL = "{0}/api/v2/Systemgroups/{1}/members" -f $JCUrlBasePath, $ByID - $resultsArray = Get-JCResults -Url $limitURL + $resultsArray = Get-JCResults -Url $limitURL -method "GET" -limit 100 } } diff --git a/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 b/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 index 3e5d5f724..334c41c8b 100644 --- a/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 +++ b/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 @@ -52,7 +52,7 @@ Function Get-JCUserGroupMember () $limitURL = "{0}/api/v2/usergroups/{1}/members" -f $JCUrlBasePath, $Group_ID Write-Debug $limitURL - $rawResults = Get-JCResults -Url $limitURL + $rawResults = Get-JCResults -Url $limitURL -method "GET" -limit 100 foreach ($uid in $rawResults) { @@ -82,7 +82,7 @@ Function Get-JCUserGroupMember () { $limitURL = "{0}/api/v2/usergroups/{1}/members" -f $JCUrlBasePath, $ByID Write-Debug $limitURL - $resultsArray = Get-JCResults -Url $limitURL + $resultsArray = Get-JCResults -Url $limitURL -method "GET" -limit 100 } } From 6c996479f55261c47f8319041b17526c17cc6d42 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 16 May 2022 15:52:55 +0000 Subject: [PATCH 10/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 4 ++-- PowerShell/ModuleBanner.md | 6 ++--- PowerShell/ModuleChangelog.md | 22 +++++++++++++++++++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 3611f0ae2..531849ba3 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 1.21.0 +Help Version: 1.22.0 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 358d701d4..e7cec7cc2 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 5/10/2022 +# Generated on: 5/16/2022 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.21.0' +ModuleVersion = '1.22.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index b169fabdc..b0b8be072 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,17 @@ #### Latest Version ``` -1.21.0 +1.22.0 ``` #### Banner Current ``` -New parameter -recoveryemail for Set, Get, New-JCUser +{{Fill in the Banner Current}} ``` #### Banner Old ``` -Get-JcUser, Set-JcUser and New-JcUser will soon be deprecating the -suspended parameter. Please use the -state paramater as a replacement. +{{Fill in the Banner Old}} ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index a10b1de35..5b832255e 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 1.22.0 + +Release Date: May 16, 2022 + +#### RELEASE NOTES + +``` +{{Fill in the Release Notes}} +``` + +#### FEATURES: + +{{Fill in the Features}} + +#### IMPROVEMENTS: + +{{Fill in the Improvements}} + +#### BUG FIXES: + +{{Fill in the Bug Fixes}} + ## 1.21.0 Release Date: May 11, 2022 From 4130f1094972420d3074447be764a150d6241c4f Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Mon, 16 May 2022 11:07:25 -0500 Subject: [PATCH 11/23] update banner/changelog --- PowerShell/ModuleBanner.md | 2 +- PowerShell/ModuleChangelog.md | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index b169fabdc..91782224e 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,7 +1,7 @@ #### Latest Version ``` -1.21.0 +1.21.1 ``` #### Banner Current diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index a10b1de35..b5578dc00 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,24 @@ +## 1.21.1 + +Release Date: May 16, 2022 + +#### RELEASE NOTES + +``` +This release includes an update to private functions that will further improve performance with gathering data from API endpoints + +``` +#### IMPROVEMENTS: + +* Get-JCResults private function updates to further improve performance with API endpoints + +#### FEATURES: + +* This release adds new parameters to Get-JCResults private function + +#### BUG FIXES: + +N/A ## 1.21.0 Release Date: May 11, 2022 From 7669d2913de6bd4aa3aafc7e9072342a1911f29b Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 16 May 2022 10:06:34 -0700 Subject: [PATCH 12/23] Manager search efficiency change --- .../Public/Users/Get-JCUser.ps1 | 35 ++++++++---------- .../Public/Users/New-JCUser.ps1 | 35 ++++++++---------- .../Public/Users/Set-JCUser.ps1 | 36 ++++++++----------- 3 files changed, 45 insertions(+), 61 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 5643d2bd1..f57fa4532 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -314,10 +314,9 @@ Function Get-JCUser () if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - filter = @{ - or = @( - '_id:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('_id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -326,10 +325,9 @@ Function Get-JCUser () # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -342,10 +340,9 @@ Function Get-JCUser () $null = [mailaddress]$EmailAddress # Search manager using email $managerSearch = @{ - filter = @{ - or = @( - 'email:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('email') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -353,10 +350,9 @@ Function Get-JCUser () $managerValue = $managerResults.id if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -367,10 +363,9 @@ Function Get-JCUser () catch { # search the username in the search endpoint $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index 08a3343f5..b8fa6b46c 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -326,10 +326,9 @@ Function New-JCUser () if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - filter = @{ - or = @( - '_id:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('_id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -338,10 +337,9 @@ Function New-JCUser () # if no value was returned, then assume the case this is actuallty a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -353,10 +351,9 @@ Function New-JCUser () try { $null = [mailaddress]$EmailAddress $managerSearch = @{ - filter = @{ - or = @( - 'email:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('email') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -365,10 +362,9 @@ Function New-JCUser () # if no value was returned, then assume the case this is actuallty a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -379,10 +375,9 @@ Function New-JCUser () catch { # search the username in the search endpoint $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 9f57efd31..0e43859c8 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -606,10 +606,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - filter = @{ - or = @( - '_id:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('_id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -618,10 +617,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -632,13 +630,11 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # Use class mailaddress to check if $param.value is email try { $null = [mailaddress]$EmailAddress - Write-Debug "This is true" # Search for manager using email $managerSearch = @{ - filter = @{ - or = @( - 'email:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('email') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -647,10 +643,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -661,10 +656,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline catch { # search the username in the search endpoint $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) From d0c9296818fca9f401475ef5dab201d4b52ba152 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 16 May 2022 17:19:25 +0000 Subject: [PATCH 13/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 19abb32ca..e7cec7cc2 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 5/13/2022 +# Generated on: 5/16/2022 # @{ From 4704993ebe56f0c11a516c3cd3cb0ceaca46211b Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Mon, 16 May 2022 18:06:33 +0000 Subject: [PATCH 14/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 4 +--- PowerShell/JumpCloud Module/JumpCloud.psd1 | 3 +-- PowerShell/ModuleBanner.md | 6 ++--- PowerShell/ModuleChangelog.md | 22 +++++++++++++++++++ 4 files changed, 27 insertions(+), 8 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 19740e029..41bd80135 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,9 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki - -Help Version: 1.22.0 - +Help Version: 1.21.1 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 2af1313b6..f3a64927e 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,8 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. - -ModuleVersion = '1.22.0' +ModuleVersion = '1.21.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index c1ff0c0c2..7fc67101e 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,17 @@ #### Latest Version ``` -1.22.0 +1.21.1 ``` #### Banner Current ``` -New parameter -recoveryemail for Set, Get, New-JCUser +{{Fill in the Banner Current}} ``` #### Banner Old ``` -Get-JcUser, Set-JcUser and New-JcUser will soon be deprecating the -suspended parameter. Please use the -state paramater as a replacement. +{{Fill in the Banner Old}} ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 11aa085bf..f97d9709f 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 1.21.1 + +Release Date: May 16, 2022 + +#### RELEASE NOTES + +``` +{{Fill in the Release Notes}} +``` + +#### FEATURES: + +{{Fill in the Features}} + +#### IMPROVEMENTS: + +{{Fill in the Improvements}} + +#### BUG FIXES: + +{{Fill in the Bug Fixes}} + ## 1.22.0 From 4253cedfb215106b788cb8ab1e8b57b1177f3da9 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Mon, 16 May 2022 13:14:00 -0700 Subject: [PATCH 15/23] Fix _id error --- PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 | 2 +- PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 | 2 +- PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index f57fa4532..01fa3e9c2 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -316,7 +316,7 @@ Function Get-JCUser () $managerSearch = @{ searchFilter = @{ searchTerm = @($param.Value) - fields = @('_id') + fields = @('id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index b8fa6b46c..e09db6ccc 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -328,7 +328,7 @@ Function New-JCUser () $managerSearch = @{ searchFilter = @{ searchTerm = @($param.Value) - fields = @('_id') + fields = @('id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 0e43859c8..8c6006a87 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -608,7 +608,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerSearch = @{ searchFilter = @{ searchTerm = @($param.Value) - fields = @('_id') + fields = @('id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) From 79ba262b04252aee2cda37d8e998f2b6517d36e7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 17 May 2022 09:00:34 -0700 Subject: [PATCH 16/23] Added email search to se-jcuser --- .../Public/Users/Set-JCUser.ps1 | 106 ++++++++---------- 1 file changed, 45 insertions(+), 61 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 8c6006a87..3976616c6 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -770,10 +770,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline { # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - filter = @{ - or = @( - '_id:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -783,10 +782,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline if (!$managerValue) { $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -797,13 +795,11 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # Use class mailaddress to check if $param.value is email try { $null = [mailaddress]$EmailAddress - Write-Debug "This is true" # Search for manager using email $managerSearch = @{ - filter = @{ - or = @( - 'email:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('email') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -812,10 +808,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -826,10 +821,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline catch { # search the username in the search endpoint $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1022,10 +1016,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline { # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - filter = @{ - or = @( - '_id:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1035,10 +1028,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline if (!$managerValue) { $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1052,10 +1044,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline Write-Debug "This is true" # Search for manager using email $managerSearch = @{ - filter = @{ - or = @( - 'email:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('email') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1064,10 +1055,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1078,10 +1068,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline catch { # search the username in the search endpoint $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1220,10 +1209,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline if (((Select-String -InputObject $param.Value -Pattern $regexPattern).Matches.value)::IsNullOrEmpty){ # if we have a 24 characterid, try to match the id using the search endpoint $managerSearch = @{ - filter = @{ - or = @( - '_id:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('id') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1232,10 +1220,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1249,10 +1236,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline Write-Debug "This is true" # Search for manager using email $managerSearch = @{ - filter = @{ - or = @( - 'email:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('email') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1261,10 +1247,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) @@ -1275,10 +1260,9 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline catch { # search the username in the search endpoint $managerSearch = @{ - filter = @{ - or = @( - 'username:$eq:' + $param.Value - ) + searchFilter = @{ + searchTerm = @($param.Value) + fields = @('username') } } $managerResults = Search-JcSdkUser -Body:($managerSearch) From b2a054933aaf116849ea39a48230daab411190f3 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Tue, 17 May 2022 16:11:48 +0000 Subject: [PATCH 17/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index e7cec7cc2..4857e343b 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 5/16/2022 +# Generated on: 5/17/2022 # @{ From 13397fb4109faae906984259ca340aa30d94597b Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Tue, 17 May 2022 16:13:32 +0000 Subject: [PATCH 18/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index f3a64927e..1309d4e23 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 5/16/2022 +# Generated on: 5/17/2022 # @{ From 987cf9292785bded98867219badcf52a736b7bf7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 17 May 2022 11:16:22 -0700 Subject: [PATCH 19/23] [Skip CI] --- PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 | 2 +- PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 | 2 +- PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 01fa3e9c2..4e8f8c8b0 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -117,7 +117,7 @@ Function Get-JCUser () [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'The managedAppleId of the JumpCloud user you wish to search for.')] [String]$managedAppleId, - [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'The manager username or ID of the JumpCloud user you wish to search for.')] + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'The manager username, primary email or ID of the JumpCloud user you wish to search for.')] [String]$manager, [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'A search filter to return users that are in an ACTIVATED, STAGED or SUSPENDED state')] diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index e09db6ccc..90e717290 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -150,7 +150,7 @@ Function New-JCUser () [string] $state, - [Parameter(ValueFromPipelineByPropertyName = $True, HelpMessage = 'The manager username or ID of the JumpCloud manager user; must be a valid user')] + [Parameter(ValueFromPipelineByPropertyName = $True, HelpMessage = 'The manager username, ID or primary email of the JumpCloud manager user; must be a valid user')] [string]$manager, [Parameter(ValueFromPipelineByPropertyName = $True, HelpMessage = 'The managedAppleId for the user')] diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 3976616c6..c47cb0cb0 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -239,7 +239,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline [nullable[bool]] $suspended, - [Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The manager username or ID of the JumpCloud manager user; must be a valid user')] + [Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The manager username, ID or primary email of the JumpCloud manager user; must be a valid user')] [string] $manager, From 8fd676653c9b2f9ef2bd22eba4a29a0ca43b1de1 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Tue, 17 May 2022 18:34:56 +0000 Subject: [PATCH 20/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleBanner.md | 8 +++---- PowerShell/ModuleChangelog.md | 22 +++++++++++++++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 531849ba3..41bd80135 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 1.22.0 +Help Version: 1.21.1 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 4857e343b..1309d4e23 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.22.0' +ModuleVersion = '1.21.1' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 78e37ca0d..7fc67101e 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,19 +1,17 @@ #### Latest Version ``` -1.22.0 +1.21.1 ``` #### Banner Current ``` -Added functionality for Set, Get, New-JCUser to Search by Email to Manager Field - +{{Fill in the Banner Current}} ``` #### Banner Old ``` -New parameter -recoveryemail for Set, Get, New-JCUser - +{{Fill in the Banner Old}} ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 9e09bd0c8..d21843d07 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 1.21.1 + +Release Date: May 17, 2022 + +#### RELEASE NOTES + +``` +{{Fill in the Release Notes}} +``` + +#### FEATURES: + +{{Fill in the Features}} + +#### IMPROVEMENTS: + +{{Fill in the Improvements}} + +#### BUG FIXES: + +{{Fill in the Bug Fixes}} + ## 1.22.0 From dde85ae604e998c0e45f73fe7e3d1c6a27528ede Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 17 May 2022 11:44:02 -0700 Subject: [PATCH 21/23] Version docs --- .circleci/workflows.yml | 2 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleBanner.md | 6 +++--- PowerShell/ModuleChangelog.md | 23 ---------------------- 4 files changed, 5 insertions(+), 28 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 8f97ecc25..8e4572fba 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -32,7 +32,7 @@ parameters: description: 'Release Type. Accepted values [ Major, Minor, Patch ]' type: enum enum: ["Major", "Minor", "Patch"] - default: "Patch" + default: "Minor" RequiredModulesRepo: description: 'PowerShell Repository for JumpCloud SDKs' type: enum diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 1309d4e23..4857e343b 100755 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.21.1' +ModuleVersion = '1.22.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 7fc67101e..855d9080a 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,17 +1,17 @@ #### Latest Version ``` -1.21.1 +1.22.0 ``` #### Banner Current ``` -{{Fill in the Banner Current}} +* Added functionality for Set, Get, New-JCUser to Search by Email to Manager Field ``` #### Banner Old ``` -{{Fill in the Banner Old}} +* New parameter -recoveryemail for Set, Get, New-JCUser ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index d21843d07..08e398466 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,26 +1,3 @@ -## 1.21.1 - -Release Date: May 17, 2022 - -#### RELEASE NOTES - -``` -{{Fill in the Release Notes}} -``` - -#### FEATURES: - -{{Fill in the Features}} - -#### IMPROVEMENTS: - -{{Fill in the Improvements}} - -#### BUG FIXES: - -{{Fill in the Bug Fixes}} - - ## 1.22.0 Release Date: May 16, 2022 From 2b3eec127547d8ffc4b87be56a7b30b690bc9088 Mon Sep 17 00:00:00 2001 From: TheJumpCloud Date: Tue, 17 May 2022 18:54:52 +0000 Subject: [PATCH 22/23] Updating PowerShell Module;[skip ci] --- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 41bd80135..531849ba3 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 1.21.1 +Help Version: 1.22.0 Locale: en-US --- From 32add5535f33bb1b60bbd04bfce51b8106712c5d Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Tue, 17 May 2022 13:10:46 -0700 Subject: [PATCH 23/23] Publish [skip ci] --- .circleci/workflows.yml | 2 +- PowerShell/ModuleChangelog.md | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 8e4572fba..fd4ddf8a4 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -45,7 +45,7 @@ parameters: PublishToPSGallery: description: 'When `true` and when run against Master branch, this workflow will publish the latest code to PSGallery' type: boolean - default: false + default: true ManualModuleVersion: description: 'When `true` the pipeline will use the Module Version specified in JumpCloud Module JumpCloud.psd1 file' type: boolean diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 08e398466..093fbbbd0 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -4,9 +4,8 @@ Release Date: May 16, 2022 #### RELEASE NOTES -``` -This release includes an update to Set, Get, New-JCUser to add the use of Email to the Manager field -``` +This release includes an update to Set, Get, New-JCUser to search manager by a valid JumpCloud user's primary email + #### IMPROVEMENTS: * Set, Get, New-JCUser will validate email address value given to -manager @@ -14,15 +13,11 @@ This release includes an update to Set, Get, New-JCUser to add the use of Email #### FEATURES: * This release adds email search to manager field in Set, Get, New-JCUser - - -#### FEATURES: - * This release adds new parameters to Get-JCResults private function #### BUG FIXES: -N/A +* Backup-JCOrganization no longer throws a forbidden error message when run with a read-only API Key. ## 1.21.0