diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml
index 68929a937..6a1c471c2 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: false
+ default: true
ManualModuleVersion:
description: 'When `true` the pipeline will use the Module Version specified in JumpCloud Module JumpCloud.psd1 file'
type: boolean
@@ -368,7 +368,8 @@ commands:
name: 'Publish Wiki Documentaiton'
shell: pwsh.exe
command: |
- ./PowerShell/Deploy/Build-WikiPages.ps1
+ Set-Location -Path "./PowerShell/Deploy/"
+ ./Build-WikiPages.ps1
invoke-script:
steps:
- checkout
diff --git a/.gitignore b/.gitignore
index 695e760d5..009f2affe 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,6 @@
.DS_Store
.vscode
# Ignore Test Results Directory
-*test_results
\ No newline at end of file
+*test_results
+# Ignore support.wiki
+*support.wiki
\ No newline at end of file
diff --git a/PowerShell/Deploy/Build-WikiPages.ps1 b/PowerShell/Deploy/Build-WikiPages.ps1
index c18f545ae..3e9705a53 100755
--- a/PowerShell/Deploy/Build-WikiPages.ps1
+++ b/PowerShell/Deploy/Build-WikiPages.ps1
@@ -2,7 +2,7 @@
###########################################################################
Invoke-GitClone -Repo:($GitSourceRepoWiki)
$SupportRepoDocs = "$FolderPath_Module/Docs"
-$SupportWiki = "$ScriptRoot/../support.wiki"
+$SupportWiki = "$ScriptRoot/support.wiki"
If (!(Test-Path -Path:($SupportWiki))) { New-Item -Path:($SupportWiki) -ItemType:('Directory') }
Set-Location -Path:($SupportWiki)
$Docs = Get-ChildItem -Path:($SupportRepoDocs + '/*.md') -Recurse
diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md
index ffe9bbdd2..8de137ccd 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.20.0
+Help Version: 1.20.1
Locale: en-US
---
diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1
index b40c847ed..bd319b64d 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: 4/7/2022
+# Generated on: 4/28/2022
#
@{
@@ -12,7 +12,7 @@
RootModule = 'JumpCloud.psm1'
# Version number of this module.
-ModuleVersion = '1.20.0'
+ModuleVersion = '1.20.1'
# Supported PSEditions
# CompatiblePSEditions = @()
diff --git a/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCResults.ps1 b/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCResults.ps1
new file mode 100644
index 000000000..a63b45c44
--- /dev/null
+++ b/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCResults.ps1
@@ -0,0 +1,44 @@
+Function Get-JCResults
+{
+ [CmdletBinding()]
+ Param(
+ [Parameter(Mandatory = $true, HelpMessage = 'URL of Endpoint')][ValidateNotNullOrEmpty()]$URL
+ )
+ begin {
+ $hdrs = @{
+ 'Content-Type' = 'application/json'
+ 'Accept' = 'application/json'
+ 'X-API-KEY' = $JCAPIKEY
+ }
+ if ($JCOrgID)
+ {
+ $hdrs.Add('x-org-id', "$($JCOrgID)")
+ }
+ $resultsArray = @()
+ $totalCount = 1
+ $limit = 100
+ $skip = 0
+ }
+ process {
+ $limitURL = $URL + "?limit=$limit&skip=$skip"
+ Write-Debug $limitURL
+ $response = Invoke-WebRequest -Method GET -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent)
+ $totalCount = $response.Headers."x-total-count"
+ $totalCount = [int]$totalCount.Trim()
+ Write-Debug "total count: $totalCount"
+ $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)
+ $resultsArray += $response.Content | ConvertFrom-Json
+ Write-Debug ("Pass: $i Amount: " + ($response.Content | ConvertFrom-Json).Count)
+ }
+ }
+ end {
+ return $resultsArray
+ }
+}
\ No newline at end of file
diff --git a/PowerShell/JumpCloud Module/Private/NestedFunctions/New-JCCommandFromURL.ps1 b/PowerShell/JumpCloud Module/Private/NestedFunctions/New-JCCommandFromURL.ps1
index e9920196c..561ebea95 100644
--- a/PowerShell/JumpCloud Module/Private/NestedFunctions/New-JCCommandFromURL.ps1
+++ b/PowerShell/JumpCloud Module/Private/NestedFunctions/New-JCCommandFromURL.ps1
@@ -22,9 +22,9 @@ Function New-JCCommandFromURL
$Command = Invoke-WebRequest -Uri $GitHubURL -UseBasicParsing -UserAgent:(Get-JCUserAgent) | Select-Object RawContent
- $CodeRaw = (($Command -split '')[1] -split '
')[0] # Contain XML escape characters
+ $CodeRaw = $Command | Select-String '(?<=\)((.|\n|\r)*?)(?=<\/code>)' # Contain XML escape characters
- $Code = ((((($CodeRaw -replace "&", "&") -replace "<", "<") -replace ">", ">") -replace """, '"') -Replace "'", "'") # Replace XML character references
+ $Code = ((((($CodeRaw.Matches.Value.Trim() -replace "&", "&") -replace "<", "<") -replace ">", ">") -replace """, '"') -Replace "'", "'") # Replace XML character references
$Name = (((((($Command -split 'Name')[1]) -replace "`n", "") -split '
)', '') diff --git a/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 b/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 index 4dffaf07d..06729ad25 100755 --- a/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 +++ b/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 @@ -171,8 +171,40 @@ Function Connect-JCOnline () { If ([System.String]::IsNullOrEmpty($env:JcUpdateModule) -or $env:JcUpdateModule -eq 'True') { - $env:JcUpdateModule = $false - Update-JCModule | Out-Null + # Update-JCModule depends on these resources being available, check if available then continue + $moduleSites = @( + 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/ModuleChangelog.md', + 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/ModuleBanner.md', + 'https://www.powershellgallery.com/packages/JumpCloud/' + ) + $downRepo = @() + foreach($site in $moduleSites){ + $HTTP_Request = [System.Net.WebRequest]::Create($site) + try { + $HTTP_Response = $HTTP_Request.GetResponse() + } + catch [System.Net.WebException]{ + $HTTP_Response = $_.Exception.Response + } + $HTTP_Status = [int]$HTTP_Response.StatusCode + If ($HTTP_Status -eq 200) {} #Site is working properly + Else { + $downRepo += $site + } + # Clean up the http request by closing it. + If ($HTTP_Response -eq $null) { } + Else { $HTTP_Response.Close() } + } + # If one of the 3 sites are inaccessible, skip running Update-JCModule + if ($downRepo.Count -ge 1) + { + Write-Verbose ("One or more of the required resources to update the JumpCloud Module are inaccessible at the moment" ) + } + else + { + $env:JcUpdateModule = $false + Update-JCModule | Out-Null + } } If ($IndShowMessages) { diff --git a/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 b/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 index 27e0b4b59..ad6b5d491 100644 --- a/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 +++ b/PowerShell/JumpCloud Module/Public/Groups/SystemGroups/Get-JCSystemGroupMember.ps1 @@ -26,23 +26,6 @@ Function Get-JCSystemGroupMember () Write-Debug 'Verifying JCAPI Key' if ($JCAPIKEY.length -ne 40) {Connect-JConline} - Write-Debug 'Populating API headers' - $hdrs = @{ - - 'Content-Type' = 'application/json' - 'Accept' = 'application/json' - 'X-API-KEY' = $JCAPIKEY - - } - - if ($JCOrgID) - { - $hdrs.Add('x-org-id', "$($JCOrgID)") - } - - [int]$limit = '100' - Write-Debug "Setting limit to $limit" - Write-Debug 'Initilizing resultsArray and results ArraryByID' $rawResults = @() $resultsArray = @() @@ -57,7 +40,6 @@ Function Get-JCSystemGroupMember () } - process { @@ -74,17 +56,8 @@ Function Get-JCSystemGroupMember () $Group_ID = $GroupNameHash.Get_Item($Group) Write-Debug "$Group_ID" - [int]$skip = 0 #Do not change! - Write-Debug "Setting skip to $skip" - - while ($rawResults.Count -ge $skip) - { - $limitURL = "$JCUrlBasePath/api/v2/Systemgroups/$Group_ID/members?limit=$limit&skip=$skip" - Write-Debug $limitURL - $results = Invoke-RestMethod -Method GET -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent) - $skip += $limit - $rawResults += $results - } + $limitURL = "{0}/api/v2/Systemgroups/{1}/members" -f $JCUrlBasePath, $Group_ID + $rawResults = Get-JCResults -Url $limitURL foreach ($uid in $rawResults) { @@ -104,7 +77,7 @@ Function Get-JCSystemGroupMember () } - else { Throw "Group does not exist. Run 'Get-JCGroup -type System' to see a list of all your JumpCloud System groups."} + else { Throw "Group does not exist. Run 'Get-JCGroup -type System' to see a list of all your JumpCloud System groups." } } } @@ -112,17 +85,8 @@ Function Get-JCSystemGroupMember () elseif ($PSCmdlet.ParameterSetName -eq 'ByID') { - [int]$skip = 0 #Do not change! - - while ($resultsArray.Count -ge $skip) - { - - $limitURL = "$JCUrlBasePath/api/v2/Systemgroups/$ByID/members?limit=$limit&skip=$skip" - Write-Debug $limitURL - $results = Invoke-RestMethod -Method GET -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent) - $skip += $limit - $resultsArray += $results - } + $limitURL = "{0}/api/v2/Systemgroups/{1}/members" -f $JCUrlBasePath, $ByID + $resultsArray = Get-JCResults -Url $limitURL } } diff --git a/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 b/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 index b269805aa..3e5d5f724 100644 --- a/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 +++ b/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 @@ -19,23 +19,6 @@ Function Get-JCUserGroupMember () Write-Debug 'Verifying JCAPI Key' if ($JCAPIKEY.length -ne 40) {Connect-JConline} - Write-Debug 'Populating API headers' - $hdrs = @{ - - 'Content-Type' = 'application/json' - 'Accept' = 'application/json' - 'X-API-KEY' = $JCAPIKEY - - } - - if ($JCOrgID) - { - $hdrs.Add('x-org-id', "$($JCOrgID)") - } - - [int]$limit = '100' - Write-Debug "Setting limit to $limit" - Write-Debug 'Initilizing resultsArray and results ArraryByID' $rawResults = @() $resultsArray = @() @@ -67,17 +50,9 @@ Function Get-JCUserGroupMember () $Group_ID = $GroupNameHash.Get_Item($Group) Write-Debug "$Group_ID" - [int]$skip = 0 #Do not change! - Write-Debug "Setting skip to $skip" - - while ($rawResults.Count -ge $skip) - { - $limitURL = "$JCUrlBasePath/api/v2/usergroups/$Group_ID/members?limit=$limit&skip=$skip" - Write-Debug $limitURL - $results = Invoke-RestMethod -Method GET -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent) - $skip += $limit - $rawResults += $results - } + $limitURL = "{0}/api/v2/usergroups/{1}/members" -f $JCUrlBasePath, $Group_ID + Write-Debug $limitURL + $rawResults = Get-JCResults -Url $limitURL foreach ($uid in $rawResults) { @@ -105,17 +80,9 @@ Function Get-JCUserGroupMember () elseif ($PSCmdlet.ParameterSetName -eq 'ByID') { - [int]$skip = 0 #Do not change! - - while ($resultsArray.Count -ge $skip) - { - - $limitURL = "$JCUrlBasePath/api/v2/usergroups/$ByID/members?limit=$limit&skip=$skip" - Write-Debug $limitURL - $results = Invoke-RestMethod -Method GET -Uri $limitURL -Headers $hdrs -UserAgent:(Get-JCUserAgent) - $skip += $limit - $resultsArray += $results - } + $limitURL = "{0}/api/v2/usergroups/{1}/members" -f $JCUrlBasePath, $ByID + Write-Debug $limitURL + $resultsArray = Get-JCResults -Url $limitURL } } diff --git a/PowerShell/JumpCloud Module/Tests/Private/NestedFunctions/Get-JCResults.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Private/NestedFunctions/Get-JCResults.Tests.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 2a3459374..119d01f6f 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,7 +1,7 @@ #### Latest Version ``` -1.20.0 +1.20.1 ``` #### Banner Current diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 6b29fcaab..e37621e73 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,21 @@ +## 1.20.1 + +Release Date: April 28, 2022 + +#### RELEASE NOTES + +``` +This releasse includes a patch to fix pagination where a null system record exists in Get-JCSystemGroupMember. +``` +#### IMPROVEMENTS: + +* Import/Update-JCUsersFromCSV will validate that custom attribute values are not null before attempting to Import/Update users. +* Addressed an issue with Update-JCModule failing if GitHub or PowerShellGallery were inaccessible + +#### BUG FIXES: + +* [Fixed issue involving Get-JCSystemGroupMember not returning all expected results](https://github.com/TheJumpCloud/support/pull/370) + ## 1.20.0 Release Date: March 31, 2022 @@ -12,6 +30,7 @@ This release incorporates the "state" parameter into Get/Set/New-JCUser [state parameter added to module](https://github.com/TheJumpCloud/support/pull/361) see [Managing User State documentation](https://support.jumpcloud.com/support/s/article/Managing-User-States#:~:text=A%20user%20state%20indicates%20where,still%20need%20to%20be%20onboarded.). + #### IMPROVEMENTS: * Import/Update-JCUsersFromCSV will validate that custom attribute values are not null before attempting to Import/Update users.