Skip to content

Commit

Permalink
Merge pull request #371 from TheJumpCloud/JumpCloudModule_1.20.1
Browse files Browse the repository at this point in the history
JumpCloud 1.20.1 Release
  • Loading branch information
gweinjc authored Apr 28, 2022
2 parents 5e5d465 + c0c948c commit ef249f8
Show file tree
Hide file tree
Showing 13 changed files with 122 additions and 93 deletions.
7 changes: 4 additions & 3 deletions .circleci/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.DS_Store
.vscode
# Ignore Test Results Directory
*test_results
*test_results
# Ignore support.wiki
*support.wiki
2 changes: 1 addition & 1 deletion PowerShell/Deploy/Build-WikiPages.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/Docs/JumpCloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
---

Expand Down
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Module/JumpCloud.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: JumpCloud Solutions Architect Team
#
# Generated on: 4/7/2022
# Generated on: 4/28/2022
#

@{
Expand All @@ -12,7 +12,7 @@
RootModule = 'JumpCloud.psm1'

# Version number of this module.
ModuleVersion = '1.20.0'
ModuleVersion = '1.20.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ Function New-JCCommandFromURL

$Command = Invoke-WebRequest -Uri $GitHubURL -UseBasicParsing -UserAgent:(Get-JCUserAgent) | Select-Object RawContent

$CodeRaw = (($Command -split '<code>')[1] -split '</code>')[0] # Contain XML escape characters
$CodeRaw = $Command | Select-String '(?<=\<code(.*?)\>)((.|\n|\r)*?)(?=<\/code>)' # Contain XML escape characters

$Code = ((((($CodeRaw -replace "&amp;", "&") -replace "&lt;", "<") -replace "&gt;", ">") -replace "&quot;", '"') -Replace "&apos;", "'") # Replace XML character references
$Code = ((((($CodeRaw.Matches.Value.Trim() -replace "&amp;", "&") -replace "&lt;", "<") -replace "&gt;", ">") -replace "&quot;", '"') -Replace "&apos;", "'") # Replace XML character references

$Name = (((((($Command -split 'Name</h4>')[1]) -replace "`n", "") -split '</p>')[0]) -replace '(\<p)(.*?)(\>)', '')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
Expand All @@ -57,7 +40,6 @@ Function Get-JCSystemGroupMember ()

}


process

{
Expand All @@ -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)
{
Expand All @@ -104,25 +77,16 @@ 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." }

}
}

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

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = @()
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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

}
}
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion PowerShell/ModuleBanner.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#### Latest Version

```
1.20.0
1.20.1
```

#### Banner Current
Expand Down
19 changes: 19 additions & 0 deletions PowerShell/ModuleChangelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down

0 comments on commit ef249f8

Please sign in to comment.