From c89a4a6df02ee62d98566987abe4353fb6fdd5d5 Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Fri, 11 Apr 2025 11:32:15 -0700 Subject: [PATCH 01/60] Merge pull request #668 from TheJumpCloud/JumpCloudModule_2.18 Jumpcloud module 2.18 From afa651f4f6fb0424402cbbb32ab9c64072784b2f Mon Sep 17 00:00:00 2001 From: Ken Maranion <97972790+kmaranionjc@users.noreply.github.com> Date: Fri, 11 Apr 2025 11:32:15 -0700 Subject: [PATCH 02/60] Merge pull request #668 from TheJumpCloud/JumpCloudModule_2.18 Jumpcloud module 2.18 --- .../JumpCloud Module/Docs/Get-JCSystem.md | 2 +- .../Docs/Get-JCUserGroupMember.md | 2 +- PowerShell/JumpCloud Module/Docs/JumpCloud.md | 2 +- .../JumpCloud Module/Docs/New-JCPolicy.md | 8 + .../JumpCloud Module/Docs/Set-JCPolicy.md | 8 + .../JumpCloud Module/Docs/Set-JCSystem.md | 18 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 4 +- .../NestedFunctions/Convert-JCUserToID.ps1 | 78 +++++ .../Get-JCPolicyTemplateConfigField.ps1 | 1 + .../Private/Policies/New-UriListItem.ps1 | 169 +++++++++ .../Policies/Set-JCPolicyConfigField.ps1 | 153 +++++++++ .../Private/Policies/Show-JCPolicyValues.ps1 | 1 - .../UserGroups/Get-JCUserGroupMember.ps1 | 4 +- .../Public/Policies/New-JCPolicy.ps1 | 89 ++++- .../Public/Policies/Set-JCPolicy.ps1 | 104 ++++++ .../Public/Systems/Get-JCSystem.ps1 | 2 +- .../Public/Systems/Set-JCSystem.ps1 | 36 +- .../Public/Users/New-JCUser.ps1 | 76 +---- .../Public/Users/Set-JCUser.ps1 | 322 +----------------- .../CSV_Import/New-JCDeviceUpdateTemplate.ps1 | 16 +- .../ReturnProperties.Tests.ps1 | 2 +- .../Convert-JCUserToID.Tests.ps1 | 0 .../Private/Policies/New-UriList.Tests.ps1 | 0 .../Public/Policies/New-JCPolicy.Tests.ps1 | 184 ++++++++++ .../Public/Policies/Set-JCPolicy.Tests.ps1 | 114 +++++++ .../Public/Systems/Set-JCSystem.Tests.ps1 | 75 +++- .../Update-JCDeviceFromCSV.Tests.ps1 | 41 ++- .../JumpCloud Module/en-Us/JumpCloud-help.xml | 26 ++ PowerShell/ModuleChangelog.md | 25 +- 29 files changed, 1148 insertions(+), 414 deletions(-) create mode 100644 PowerShell/JumpCloud Module/Private/NestedFunctions/Convert-JCUserToID.ps1 create mode 100644 PowerShell/JumpCloud Module/Private/Policies/New-UriListItem.ps1 create mode 100644 PowerShell/JumpCloud Module/Tests/Private/NestedFunctions/Convert-JCUserToID.Tests.ps1 create mode 100644 PowerShell/JumpCloud Module/Tests/Private/Policies/New-UriList.Tests.ps1 diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCSystem.md b/PowerShell/JumpCloud Module/Docs/Get-JCSystem.md index d8c741a9c..47c6ad5cf 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCSystem.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCSystem.md @@ -357,7 +357,7 @@ Valid properties that can be returned are: 'created', 'active', 'agentVersion', Type: System.String[] Parameter Sets: SearchFilter Aliases: -Accepted values: acknowledged, active, agentVersion, allowMultiFactorAuthentication, allowPublicKeyAuthentication, allowSshPasswordAuthentication, allowSshRootLogin, arch, azureAdJoined, connectionHistory, created, displayName, domainInfo, fde, fileSystem, hasServiceAccount, hostname, lastContact, mdm, modifySSHDConfig, networkInterfaces, organization, os, osFamily, provisionMetadata, remoteIP, serialNumber, serviceAccountState, sshdParams, systemInsights, systemTimezone, templateName, userMetrics, usernameHashes, version, hwVendor, secureLogin, displayManager, amazonInstanceID, archFamily, builtInCommands, description, osVersionDetail, policyStats, desktopCapable, sshRootEnabled, isPolicyBound +Accepted values: acknowledged, active, agentVersion, allowMultiFactorAuthentication, allowPublicKeyAuthentication, allowSshPasswordAuthentication, allowSshRootLogin, arch, azureAdJoined, connectionHistory, created, displayName, domainInfo, fde, fileSystem, hasServiceAccount, hostname, lastContact, mdm, modifySSHDConfig, networkInterfaces, organization, os, osFamily, primarySystemUser, provisionMetadata, remoteAssistAgentVersion, remoteIP, serialNumber, serviceAccountState, sshdParams, systemInsights, systemTimezone, templateName, userMetrics, usernameHashes, version, hwVendor, secureLogin, displayManager, amazonInstanceID, archFamily, builtInCommands, description, osVersionDetail, policyStats, desktopCapable, sshRootEnabled, isPolicyBound Required: False Position: Named diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCUserGroupMember.md b/PowerShell/JumpCloud Module/Docs/Get-JCUserGroupMember.md index db82cbe0b..db9914378 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCUserGroupMember.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCUserGroupMember.md @@ -56,7 +56,7 @@ If searching for a User Group using the GroupID populate the GroupID in the -ByI ```yaml Type: System.String Parameter Sets: ByID -Aliases: +Aliases: GroupID Required: True Position: Named diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index b28a8d9e2..d576f33ae 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: 2.17.0 +Help Version: 2.18.0 Locale: en-Us --- diff --git a/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md b/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md index 47fe825c7..ceced17d8 100644 --- a/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md +++ b/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md @@ -82,6 +82,14 @@ PS C:\> New-JCPolicy -TemplateName windows_Advanced:_Custom_Registry_Keys -Name This command would create a new Windows Custom Registry Policy named "Windows - Imported Custom Registry Settings" and populate the values from a registry file. .Reg registry files can be passed into New-JCPolicy as long as the TemplateName is specified with the corresponding "windows_Advanced:\_Custom_Registry_Keys" template. .Reg files will be converted and uploaded to the JumpCloud policy as long as they contain "DWORD", "EXPAND_SZ", "MULTI_SZ", "SZ" or "QWORD" type data. +### Example 6 + +```PowerShell +PS C:\> New-JCPolicy -TemplateName custom_oma_uri_mdm_windows -Name "Windows - Custom OMA MDM Policy" -uriList '(@( @{format = "string"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage; value = "pathToImage" }, @{format = "int"; uri = "./Device/Vendor/MSFT/Policy/Config/DeviceLock/AccountLockoutPolicy"; value = "1" } ))' +``` + +This command creates a JumpCloud policy named "Windows - Custom OMA MDM Policy" using the custom_oma_uri_mdm_windows template. It defines two OMA-URI configurations: a string value for EnforceLockScreenAndLogonImage and an integer value for AccountLockoutPolicy. + ## PARAMETERS ### -Name diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md b/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md index 2af62fd6e..9445a5cc9 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md @@ -90,6 +90,14 @@ PS C:\> Set-JCPolicy -PolicyName "Windows - Imported Custom Registry Settings" This command would overwrite the registry policy's existing values with the imported set of .Reg keys specified by the "RegistryFile" parameter. .Reg files will be converted and uploaded to the JumpCloud policy as long as they contain "DWORD", "EXPAND_SZ", "MULTI_SZ", "SZ" or "QWORD" type data. +### Example 7 + +```powershell +PS C:\> Set-JCPolicy -PolicyName "Windows - Custom OMA MDM Policy" -uriList '(@( @{format = "string"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage; value = "pathToImage" }, @{format = "int"; uri = "./Device/Vendor/MSFT/Policy/Config/DeviceLock/AccountLockoutPolicy"; value = "2" } ))' +``` + +This command modifies the existing JumpCloud policy named "Windows - Custom OMA MDM Policy". It updates the policy's OMA-URI settings using the -uriList parameter. The EnforceLockScreenAndLogonImage setting, a string, remains set to "pathToImage". The AccountLockoutPolicy setting, an integer, is updated from its previous value to "2", effectively changing the account lockout policy configuration. + ## PARAMETERS ### -NewName diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSystem.md b/PowerShell/JumpCloud Module/Docs/Set-JCSystem.md index 52c1cb175..b51f30723 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSystem.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSystem.md @@ -16,7 +16,8 @@ Updates an existing JumpCloud System Set-JCSystem [-SystemID] [-displayName ] [-description ] [-allowSshPasswordAuthentication ] [-allowSshRootLogin ] [-allowMultiFactorAuthentication ] [-allowPublicKeyAuthentication ] - [-systemInsights ] [] + [-systemInsights ] [-primarySystemUser ] + [] ``` ## DESCRIPTION @@ -133,6 +134,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -primarySystemUser +A string value indicating a JumpCloud users email, username or userID. This will add the user to the device associations + +```yaml +Type: System.Object +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -SystemID The _id of the System which you want to remove from JumpCloud. The SystemID will be the 24 character string populated for the _id field. diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index cd1ebbf1b..a2e806363 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,7 +3,7 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 1/3/2025 +# Generated on: 4/11/2025 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '2.17.0' +ModuleVersion = '2.18.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/JumpCloud Module/Private/NestedFunctions/Convert-JCUserToID.ps1 b/PowerShell/JumpCloud Module/Private/NestedFunctions/Convert-JCUserToID.ps1 new file mode 100644 index 000000000..61358ff69 --- /dev/null +++ b/PowerShell/JumpCloud Module/Private/NestedFunctions/Convert-JCUserToID.ps1 @@ -0,0 +1,78 @@ +function Convert-JCUserToID { + [CmdletBinding(DefaultParameterSetName = 'Default')] + Param( + [Parameter(Mandatory = $true, ValueFromPipelineByPropertyName = $true, Position = 0, HelpMessage = 'The username, id or email of a user')][ValidateNotNullOrEmpty()] + [System.String]$UserIdentifier + ) + process { + # First check if UserIdentifier returns valid user with id + # Regex match a userid + $regexPattern = [Regex]'^[a-z0-9]{24}$' + if (((Select-String -InputObject $UserIdentifier -Pattern $regexPattern).Matches.value)::IsNullOrEmpty) { + # if we have a 24 characterid, try to match the id using the search endpoint + $UserIdentifierSearch = @{ + filter = @{ + 'and' = @( + @{'_id' = @{'$eq' = "$($UserIdentifier)" } } + ) + } + fields = 'id' + } + $UserIdentifierResults = Search-JcSdkUser -Body:($UserIdentifierSearch) + # Set UserIdentifierValue; this is a validated user id + $UserIdentifierValue = $UserIdentifierResults.id + } else { + # Use class mailaddress to check if $_.value is email + try { + $null = [mailaddress]$UserIdentifier + Write-Debug "This is true" + # Search for UserIdentifier using email + $UserIdentifierSearch = @{ + filter = @{ + 'and' = @( + @{'email' = @{'$regex' = "(?i)(`^$($UserIdentifier)`$)" } } + ) + } + fields = 'email' + } + $UserIdentifierResults = Search-JcSdkUser -Body:($UserIdentifierSearch) + # Set UserIdentifierValue; this is a validated user id + $UserIdentifierValue = $UserIdentifierResults.id + # if no value was returned, then assume the case this is actually a username and search + if (!$UserIdentifierValue) { + $UserIdentifierSearch = @{ + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($UserIdentifier)`$)" } } + ) + } + fields = 'username' + } + $UserIdentifierResults = Search-JcSdkUser -Body:($UserIdentifierSearch) + # Set UserIdentifierValue from the matched username + $UserIdentifierValue = $UserIdentifierResults.id + } + } catch { + # search the username in the search endpoint + $UserIdentifierSearch = @{ + filter = @{ + 'and' = @( + @{'username' = @{'$regex' = "(?i)(`^$($UserIdentifier)`$)" } } + ) + } + fields = 'username' + } + $UserIdentifierResults = Search-JcSdkUser -Body:($UserIdentifierSearch) + # Set UserIdentifierValue from the matched username + $UserIdentifierValue = $UserIdentifierResults.id + } + } + } + end { + if ($null -eq $UserIdentifierValue) { + throw "Could not validate $UserIdentifier. Please ensure the information was entered correctly." + } else { + return $UserIdentifierValue + } + } +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Private/Policies/Get-JCPolicyTemplateConfigField.ps1 b/PowerShell/JumpCloud Module/Private/Policies/Get-JCPolicyTemplateConfigField.ps1 index 7f1fb756e..5ec3640bc 100644 --- a/PowerShell/JumpCloud Module/Private/Policies/Get-JCPolicyTemplateConfigField.ps1 +++ b/PowerShell/JumpCloud Module/Private/Policies/Get-JCPolicyTemplateConfigField.ps1 @@ -22,6 +22,7 @@ function Get-JCPolicyTemplateConfigField { file = 'file' select = 'multi' number = 'int' + multiList = 'multilist' } } process { diff --git a/PowerShell/JumpCloud Module/Private/Policies/New-UriListItem.ps1 b/PowerShell/JumpCloud Module/Private/Policies/New-UriListItem.ps1 new file mode 100644 index 000000000..06af7b7f6 --- /dev/null +++ b/PowerShell/JumpCloud Module/Private/Policies/New-UriListItem.ps1 @@ -0,0 +1,169 @@ +function New-UriListItem { + [CmdletBinding()] + param ( + [Parameter(Mandatory = $false)] + [System.String]$uri, + + [Parameter(Mandatory = $false)] + [ValidateSet('int', 'string', 'chr', 'boolean', 'bool', 'float', 'xml', 'base64', 'b64')] + [System.String]$format, + + [Parameter(Mandatory = $false)] + [System.String]$value + ) + + process { + if (-not $uri -or -not $format -or -not $value) { + Write-Host "Please provide the URI, format, and value." + $uri = Read-Host "Enter URI" + + do { + $format = Read-Host "Enter format (int, string, boolean, float, xml, base64)" + if ($format -notin ('int', 'string', 'boolean', 'float', 'xml', 'base64')) { + Write-Warning "Invalid format. Please enter one of the following: int, string, boolean, float, xml, base64" + } + } while ($format -notin ('int', 'string', 'boolean', 'float', 'xml', 'base64')) + + $isValidValue = $false + do { + $value = Read-Host "Enter the value: (format: $format)" + + switch ($format) { + 'int' { + try { + $validateInt = [int]$value + $isValidValue = $true + } catch { + Write-Warning "Invalid integer value. Please enter a valid integer number." + } + + } + 'float' { + try { + $validateFloat = [float]$value + $isValidValue = $true + } catch { + Write-Warning "Invalid float value. Please enter a valid float number." + } + + } + 'boolean' { + try { + $validateBoolean = [System.Convert]::ToBoolean($value) + $isValidValue = $true + $format = 'bool' # API expects boolean to be passed as bool + } catch { + Write-Warning "Invalid boolean value. Please enter 'true' or 'false'." + } + } + 'string' { + $isValidValue = $true + # Convert the format string to chr since it is default for the API + $format = 'chr' # API expects a string value for chr, so we can just return the string as is. + } + 'xml' { + # Convert to XML + try { + $validateXml = [xml]$value + $isValidValue = $true + } catch { + Write-Warning "Invalid XML value. Please enter a valid XML string." + } + } + 'base64' { + try { + $validateBase64 = [void][Convert]::FromBase64String($value) + $isValidValue = $true + $format = 'b64' # API expects base64 to be passed as b64 + } catch { + Write-Warning "Invalid base64 value. Please enter a valid base64 string." + } + + } + default { + Write-Warning "Invalid format. Please enter int, string, float, xml, boolean, or base64." + $isValidValue = $false + } + } + + } while (!$isValidValue) + } else { + $isValidValue = $false; + try { + switch ($format) { + 'int' { + try { + [int]$value + $isValidValue = $true + } catch { + throw "Invalid integer value. Please enter a valid integer number." + } + + } + 'float' { + try { + [float]$value + $isValidValue = $true + } catch { + throw "Invalid float value. Please enter a valid float number." + } + + } + 'boolean' { + try { + [System.Convert]::ToBoolean($value) + $isValidValue = $true + $format = 'bool' # API expects boolean to be passed as bool + } catch { + throw "Invalid boolean value. Please enter 'true' or 'false'." + } + } + 'string' { + try { + $format = 'chr' # API expects a string value for chr, so we can just return the string as is. + $isValidValue = $true + } catch { + throw "Invalid string value. Please enter a valid string." + } + } + 'xml' { + try { + [xml]$value + $isValidValue = $true + } catch { + throw "Invalid XML value. Please enter a valid XML string." + } + } + 'base64' { + try { + $format = 'b64' # API expects base64 to be passed as b64 + [Convert]::FromBase64String($value) + $isValidValue = $true + } catch { + throw "Invalid base64 value. Please enter a valid base64 string." + } + } + default { + throw "Invalid format. Please enter int, string, float, xml, boolean, or base64." + } + } + } catch { + Write-Warning "Invalid value for format '$format'. Please check parameters." + } + if (!($isValidValue)) { + return @() + } + } + + } end { + # Create the object + # Return the object as a list item + $uriListItem = [PSCustomObject]@{ + format = $format + uri = $uri + value = $value + } + # Return the object + return $uriListItem + } +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Private/Policies/Set-JCPolicyConfigField.ps1 b/PowerShell/JumpCloud Module/Private/Policies/Set-JCPolicyConfigField.ps1 index 93eb0900f..01c4ac00e 100644 --- a/PowerShell/JumpCloud Module/Private/Policies/Set-JCPolicyConfigField.ps1 +++ b/PowerShell/JumpCloud Module/Private/Policies/Set-JCPolicyConfigField.ps1 @@ -260,6 +260,159 @@ function Set-JCPolicyConfigField { # finally update values $policyValues[$fieldIndex].value = $ValueObject } + 'multilist' { + # Test + # $policyValues[$fieldIndex].value = @( + # @{ format = "int"; uri = "a"; value = "2" }, + # @{ format = "string"; uri = "b"; value = "test" }, + # @{ format = "bool"; uri = "c"; value = "true" } + # ) + $Title = "JumpCloud Policy Field Editor" + $Message = "Select an Action:" + $Modify = New-Object System.Management.Automation.Host.ChoiceDescription "&Modify", "Modify - edit existing rows" + $Add = New-Object System.Management.Automation.Host.ChoiceDescription "&Add", "Add - add new table rows" + $Remove = New-Object System.Management.Automation.Host.ChoiceDescription "&Remove", "Remove - remove existing rows" + $Continue = New-Object System.Management.Automation.Host.ChoiceDescription "&Continue", "Continue - save/ update policy" + $Options = [System.Management.Automation.Host.ChoiceDescription[]]($Modify, $Add, $Remove, $Continue) + $multiListValues = New-Object System.Collections.ArrayList + $ValueObject = New-Object System.Collections.ArrayList + if ($policyValues[$fieldIndex].value) { + # Create a table to view + if ($ValueObject) { + $valueDisplay = New-Object System.Collections.ArrayList + for ($i = 0; $i -lt $ValueObject.Count; $i++) { + $valueDisplay.Add([PSCustomObject]@{ + row = $i + value = $ValueObject[$i] + }) | Out-Null + } + $valueDisplay | Format-Table row, @{Label = "format"; Expression = { $_.value | Select-Object -ExpandProperty format } }, @{Label = "uri"; Expression = { $_.value | Select-Object -ExpandProperty uri } }, @{Label = "value"; Expression = { $_.value | Select-Object -ExpandProperty value } } | Out-Host + } else { + # If values, populate value display + $ValueObject = New-Object System.Collections.ArrayList + $valueDisplay = New-Object System.Collections.ArrayList + for ($i = 0; $i -lt $policyValues[$fieldIndex].value.Count; $i++) { + $valueDisplay.Add([PSCustomObject]@{ + row = $i + value = $policyValues[$fieldIndex].value[$i] + }) | Out-Null + $ValueObject.Add($policyValues[$fieldIndex].value[$i]) | Out-Null + } + $valueDisplay | Format-Table row, @{Label = "format"; Expression = { $_.value | Select-Object -ExpandProperty format } }, @{Label = "uri"; Expression = { $_.value | Select-Object -ExpandProperty uri } }, @{Label = "value"; Expression = { $_.value | Select-Object -ExpandProperty value } } | Out-Host + $userChoice = $host.ui.PromptForChoice($title, $message, $options, 0) + } + + switch ($userChoice) { + 0 { + # Modify existing: + do { + $rowNum = (Read-Host "Please enter row number you wish to modify (0 - $($ValueObject.count - 1)) ") + } While (0..[int](($ValueObject).Count - 1) -notcontains $rownum -or '' -eq $rowNum) + # Get the row value + $multListRow = New-UriListItem + $ValueObject[$rowNum] = $multListRow + } + 1 { + # Add new row + $multiListValue = New-UriListItem + # Convert to a custom object + #$test = @( @{format = "int"; uri = "aasdadsdas"; value = "5" }, @{format = "string"; uri = "b"; value = "test" }, @{format = "bool"; uri = "c"; value = "true" } ) + $ValueObject.Add($multiListValue) | Out-Null + # Output the object + #$ValueObject | Format-Table + } + 2 { + # Remove existing: + [System.Collections.ARRAYLIST]$ValueObjectCopy = $ValueObject + do { + $rowNum = (Read-Host "Please enter row number you wish to remove (0 - $($ValueObject.count - 1)) ") + } While (0..[int](($ValueObject).Count - 1) -notcontains $rownum -or '' -eq $rowNum) + $ValueObjectCopy.RemoveAt($rowNum) | Out-Null + $ValueObject = $ValueObjectCopy + } + 3 { + break + } + } + } else { + do { + $validFormat = $false # Initialize to false for the while loop + + do { + Write-Host "Please enter the format and value for the new entry." + $format = Read-Host "Enter the format (int, string, float, xml, boolean, base64) for the value" + $value = Read-Host "Enter the value" + + # Validate format and value + switch ($format) { + 'int' { + try { + $value = [int]$value + $validFormat = $true + } catch { + Write-Warning "Invalid integer value. Please try again." + } + } + 'float' { + try { + $value = [double]$value + $validFormat = $true + } catch { + Write-Warning "Invalid float value. Please try again." + } + } + 'boolean' { + try { + $value = [System.Convert]::ToBoolean($value) # Attempt to convert to boolean + $validFormat = $true + $format = 'bool' # API expects boolean to be passed as bool + } catch { + Write-Warning "Invalid boolean value. Please enter 'true' or 'false'." + } + } + 'string' { + $validFormat = $true + $format = 'chr' + } # String always valid + 'xml' { + try { + $validateXml = [xml]$value #attempt xml conversion. + $validFormat = $true + } catch { + write-warning "Invalid xml. Please try again." + } + } + 'base64' { + try { + $testValue = [convert]::FromBase64String($value) + $validFormat = $true + $format = 'b64' # API expects base64 to be passed as b64 + } catch { + write-warning "Invalid base64 string. please try again." + } + + } + default { + Write-Warning "Invalid format. Please enter int, string, float, xml, boolean, or base64." + } + } + } while (!$validFormat) + + $uri = Read-Host "Enter the URI for the value" + $multiListValues = [PSCustomObject]@{ + uri = $uri + value = $value # This will be the validated value based on the format + format = $format + } + + $ValueObject.Add($multiListValues) | Out-Null + + $addMore = Read-Host "Add another value? (y/n)" + } while ($addMore -eq 'y') + } + + $policyValues[$fieldIndex].value = $ValueObject + } } } } diff --git a/PowerShell/JumpCloud Module/Private/Policies/Show-JCPolicyValues.ps1 b/PowerShell/JumpCloud Module/Private/Policies/Show-JCPolicyValues.ps1 index f41e3afca..695f76fbd 100644 --- a/PowerShell/JumpCloud Module/Private/Policies/Show-JCPolicyValues.ps1 +++ b/PowerShell/JumpCloud Module/Private/Policies/Show-JCPolicyValues.ps1 @@ -44,7 +44,6 @@ function Show-JCPolicyValues { $policyArray.Add($policyValue) | Out-Null $counter++ } - # If the policy is a registry policy, do not display value table if ($policyObject.configFieldName -notcontains "customRegTable") { # Display policy object array diff --git a/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 b/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 index 6d4d72ac2..a02a06324 100644 --- a/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 +++ b/PowerShell/JumpCloud Module/Public/Groups/UserGroups/Get-JCUserGroupMember.ps1 @@ -6,13 +6,13 @@ Function Get-JCUserGroupMember () { [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'ByGroup', Position = 0, HelpMessage = 'The name of the JumpCloud User Group you want to return the members of.')] [Alias('name')][String]$GroupName, [Parameter(Mandatory, ValueFromPipelineByPropertyName, ParameterSetName = 'ByID', HelpMessage = 'If searching for a User Group using the GroupID populate the GroupID in the -ByID field.')] - [String]$ByID + [Alias('GroupID')][String]$ByID ) begin { Write-Debug 'Verifying JCAPI Key' if ([System.String]::IsNullOrEmpty($JCAPIKEY)) { - Connect-JConline + Connect-JCOnline } $Parallel = $JCConfig.parallel.Calculated diff --git a/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 b/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 index 9f66bb074..0c580f579 100644 --- a/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 +++ b/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 @@ -87,6 +87,9 @@ function New-JCPolicy { 'exclude' { Continue } + 'multilist' { + $paramType = [system.object[]] + } Default { $paramType = 'string' } @@ -155,7 +158,6 @@ function New-JCPolicy { if ($templateObject.objectMap[$i].configFieldName -in $params.keys) { $keyName = $params.keys | Where-Object { $_ -eq $templateObject.objectMap[$i].configFieldName } $keyValue = $params.$KeyName - # write-host "Setting value from $($keyName) $($KeyValue)" switch ($templateObject.objectMap[$i].type) { 'multi' { $templateObject.objectMap[$i].value = $(($templateObject.objectMap[$i].validation | Where-Object { $_.Values -eq $keyValue }).keys) @@ -213,6 +215,89 @@ function New-JCPolicy { } $templateObject.objectMap[$i].value = $regRows } + 'multilist' { + if ($templateObject.objectMap[$i].configFieldName -eq "uriList") { + for ($j = 0; $j -lt $keyValue.Count; $j++) { + $item = $keyValue[$j] + # If uri, format, or value is null or empty, throw an error + if (!$item.uri -or !$item.format -or !$item.value) { + throw "Invalid value at index $j : uri, format, and value cannot be null or empty." + } else { + switch ($item.format) { + "base64" { + try { + $validateBase64 = [Convert]::FromBase64String($item.value) | Out-Null + $item.format = "b64" # API expects "b64" for base64 format + } catch { + throw "Invalid Base64 value at index $j : $($item.value)" + } + } + "b64" { + # Do nothing, already set to b64 + try { + $validateBase64 = [Convert]::FromBase64String($item.value) | Out-Null + } catch { + throw "Invalid Base64 value at index $j : $($item.value)" + } + } + "string" { + $item.format = "chr" # API expects "chr" for string format + } + "chr" { + # Do nothing, already set to chr + } + "boolean" { + try { + $validateBoolean = [System.Convert]::ToBoolean($item.value) | Out-Null + $item.format = "bool" # API expects "bool" for boolean format + } catch { + # Handle the case where the string is not a valid boolean + throw "Invalid boolean value at index $j : $($item.value). Please enter 'true' or 'false'." + } + } + "bool" { + # Do nothing, already set to bool + try { + $validateBoolean = [System.Convert]::ToBoolean($item.value) | Out-Null + } catch { + # Handle the case where the string is not a valid boolean + throw "Invalid boolean value at index $j : $($item.value). Please enter 'true' or 'false'." + } + } + "float" { + try { + $validateFloat = [float]$item.value + } catch { + throw "Invalid float value at index $j : $($item.value)" + } + } + "int" { + try { + $validateInt = [int]$item.value | Out-Null + } catch { + throw "Invalid int value at index $j : $($item.value)" + } + } + "xml" { + try { + $validateXml = [xml]$item.value + } catch { + throw "Invalid xml value at index $j : $($item.value)" + } + } + default { + throw "Unsupported format '$($item.format)' at index $j. No conversion performed." + } + } + } + $keyValue[$j] = $item + } + $templateObject.objectMap[$i].value = $keyValue + } else { + # For other multilist types, just pass the array + $templateObject.objectMap[$i].value = $keyValue + } + } Default { $templateObject.objectMap[$i].value = $($keyValue) } @@ -259,7 +344,6 @@ function New-JCPolicy { $updatedPolicyObject = $updatedPolicyObject | Select-Object configFieldID, configFieldName, value } } - # Validate PolicyObject if ($updatedPolicyObject) { $updatedPolicyObject | ForEach-Object { @@ -283,7 +367,6 @@ function New-JCPolicy { } | ConvertTo-Json -Depth 99 } - $headers = @{ 'x-api-key' = $env:JCApiKey 'x-org-id' = $env:JCOrgId diff --git a/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 b/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 index 81146301e..aea7b3322 100644 --- a/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 +++ b/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 @@ -91,6 +91,9 @@ function Set-JCPolicy { 'table' { $paramType = [system.object[]] } + 'multilist' { + $paramType = [system.object[]] + } 'exclude' { Continue } @@ -247,6 +250,106 @@ function Set-JCPolicy { } $templateObject.objectMap[$i].value = $regRows } + 'multilist' { + if ($templateObject.objectMap[$i].configFieldName -eq "uriList") { + $uriListProperties = $templateObject.objectMap[$i].defaultValue | Get-Member -MemberType NoteProperty + $ObjectProperties = if ($keyValue | Get-Member -MemberType NoteProperty) { + # for lists get note properties + ($keyValue | Get-Member -MemberType NoteProperty).Name + } else { + # for single objects, get keys + $keyValue.keys + } + $uriListProperties | ForEach-Object { + if ($_.Name -notin $ObjectProperties) { + Throw "Custom Windows MDM Policy require a `"$($_.Name)`" data string. The following data types were found: $($ObjectProperties)" + } + } + # uriList type validation + $validFormatTypes = @('int', 'string', 'chr', 'boolean', 'bool', 'float', 'xml', 'base64', 'b64' ) + $validFormat = $false + + $listRows = New-Object System.Collections.ArrayList + + # Loop through each item in the keyValue array + for ($j = 0; $j -lt $keyValue.Count; $j++) { + $item = $keyValue[$j] + # Validate if item.value is null or empty + # Ensure the item has a value and format and URI + if (!$item.uri -or !$item.format -or !$item.value) { + throw "Missing required fields 'uri', 'format', or 'value' at index $j in the uriList. Please ensure all items have these fields." + } else { + switch ($item.format) { + "base64" { + try { + $validateBase64 = [Convert]::FromBase64String($item.value) | Out-Null + $item.format = "b64" # API expects "b64" for base64 format + } catch { + throw "Invalid Base64 value at index $j : $($item.value)" + } + } + "b64" { + # Do nothing, already set to b64 + try { + $validateBase64 = [Convert]::FromBase64String($item.value) | Out-Null + } catch { + throw "Invalid Base64 value at index $j : $($item.value)" + } + } + "string" { + $item.format = "chr" # API expects "chr" for string format + } + "chr" { + # Do nothing, already set to chr + } + "boolean" { + try { + $validateBoolean = [System.Convert]::ToBoolean($item.value) | Out-Null + $item.format = "bool" # API expects "bool" for boolean format + } catch { + # Handle the case where the string is not a valid boolean + throw "Invalid boolean value at index $j : $($item.value). Please enter 'true' or 'false'." + } + } + "bool" { + # Do nothing, already set to bool + try { + $validateBoolean = [System.Convert]::ToBoolean($item.value) | Out-Null + } catch { + # Handle the case where the string is not a valid boolean + throw "Invalid boolean value at index $j : $($item.value). Please enter 'true' or 'false'." + } + } + "float" { + try { + $validateFloat = [float]$item.value + } catch { + throw "Invalid float value at index $j : $($item.value)" + } + } + "int" { + try { + $validateInt = [int]$item.value | Out-Null + } catch { + throw "Invalid int value at index $j : $($item.value)" + } + } + "xml" { + try { + $validateXml = [xml]$item.value + } catch { + throw "Invalid xml value at index $j : $($item.value)" + } + } + default { + throw "Unsupported format '$($item.format)' at index $j. No conversion performed." + } + } + } + } + $templateObject.objectMap[$i].value = $keyValue + } + } Default { $templateObject.objectMap[$i].value = $($keyValue) } @@ -328,6 +431,7 @@ function Set-JCPolicy { } } } + if ($updatedPolicyObject) { $body = [PSCustomObject]@{ name = $policyNameFromProcess diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 index 1952f2b9f..a459133fa 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 @@ -153,7 +153,7 @@ Function Get-JCSystem () { ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'Allows you to return select properties on JumpCloud system objects. Specifying what properties are returned can drastically increase the speed of the API call with a large data set. Valid properties that can be returned are: ''created'', ''active'', ''agentVersion'', ''allowMultiFactorAuthentication'', ''allowPublicKeyAuthentication'', ''allowSshPasswordAuthentication'', ''allowSshRootLogin'', ''arch'', ''created'', ''displayName'', ''hostname'', ''lastContact'', ''modifySSHDConfig'', ''organization'', ''os'', ''remoteIP'', ''serialNumber'', ''sshdParams'', ''systemTimezone'', ''templateName'', ''version'', ''hwVendor'',''secureLogin'',''displayManager'',''amazonInstanceID'',''archFamily'',''builtInCommands'',''description'',''osVersionDetail'',''policyStats'',''desktopCapable'', ''sshRootEnabled''')] - [ValidateSet('acknowledged', 'active', 'agentVersion', 'allowMultiFactorAuthentication', 'allowPublicKeyAuthentication', 'allowSshPasswordAuthentication', 'allowSshRootLogin', 'arch', 'azureAdJoined', 'connectionHistory', 'created', 'displayName', 'domainInfo', 'fde', 'fileSystem', 'hasServiceAccount', 'hostname', 'lastContact', 'mdm', 'modifySSHDConfig', 'networkInterfaces', 'organization', 'os', 'osFamily', 'provisionMetadata', 'remoteIP', 'serialNumber', 'serviceAccountState', 'sshdParams', 'systemInsights', 'systemTimezone', 'templateName', 'userMetrics', 'usernameHashes', 'version', 'hwVendor', 'secureLogin', 'displayManager', 'amazonInstanceID', 'archFamily', 'builtInCommands', 'description', 'osVersionDetail', 'policyStats', 'desktopCapable', 'sshRootEnabled', 'isPolicyBound')] + [ValidateSet('acknowledged', 'active', 'agentVersion', 'allowMultiFactorAuthentication', 'allowPublicKeyAuthentication', 'allowSshPasswordAuthentication', 'allowSshRootLogin', 'arch', 'azureAdJoined', 'connectionHistory', 'created', 'displayName', 'domainInfo', 'fde', 'fileSystem', 'hasServiceAccount', 'hostname', 'lastContact', 'mdm', 'modifySSHDConfig', 'networkInterfaces', 'organization', 'os', 'osFamily', 'primarySystemUser', 'provisionMetadata', 'remoteAssistAgentVersion', 'remoteIP', 'serialNumber', 'serviceAccountState', 'sshdParams', 'systemInsights', 'systemTimezone', 'templateName', 'userMetrics', 'usernameHashes', 'version', 'hwVendor', 'secureLogin', 'displayManager', 'amazonInstanceID', 'archFamily', 'builtInCommands', 'description', 'osVersionDetail', 'policyStats', 'desktopCapable', 'sshRootEnabled', 'isPolicyBound')] [String[]]$returnProperties ) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Set-JCSystem.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Set-JCSystem.ps1 index 1a2cf3cec..6c01205e1 100644 --- a/PowerShell/JumpCloud Module/Public/Systems/Set-JCSystem.ps1 +++ b/PowerShell/JumpCloud Module/Public/Systems/Set-JCSystem.ps1 @@ -35,14 +35,17 @@ Function Set-JCSystem () { [Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'Setting this value to $true will enable systemInsights and collect data for this system. Setting this value to $false will disable systemInsights and data collection for the system.')] [bool] - $systemInsights + $systemInsights, + + [Parameter(ValueFromPipelineByPropertyName = $false, HelpMessage = 'A value indicating a JumpCloud users email, username or userID. This will add the user to the device associations')] + $primarySystemUser ) begin { Write-Debug 'Verifying JCAPI Key' if ([System.String]::IsNullOrEmpty($JCAPIKEY)) { - Connect-JConline + Connect-JCOnline } $hdrs = @{ @@ -63,15 +66,12 @@ Function Set-JCSystem () { $body = @{ } foreach ($param in $PSBoundParameters.GetEnumerator()) { - if ([System.Management.Automation.PSCmdlet]::CommonParameters -contains $param.key) { continue } - if ($param.key -eq 'SystemID', 'JCAPIKey') { continue } - if ($param.key -eq 'systemInsights') { $state = switch ($systemInsights) { true { @@ -84,27 +84,33 @@ Function Set-JCSystem () { $body.add('systemInsights', @{'state' = $state }) continue } - + if ($param.key -eq "primarySystemUser") { + $userInfo = $param.value + if ($param.Value -eq $null -or $param.Value -eq "") { + $body.add("primarySystemUser.id", $null) + continue + } else { + try { + $primarySystemUserValue = Convert-JCUserToID -UserIdentifier $userInfo + $body.add("primarySystemUser.id", $primarySystemUserValue) + } catch { + Write-Warning "Could not validate $userinfo. Please ensure the user information is correct" + } + continue + } + } $body.add($param.Key, $param.Value) - } $jsonbody = $body | ConvertTo-Json - Write-Debug $jsonbody - $URL = "$JCUrlBasePath/api/systems/$SystemID" - Write-Debug $URL - $System = Invoke-RestMethod -Method PUT -Uri $URL -Body $jsonbody -Headers $hdrs -UserAgent:(Get-JCUserAgent) $UpdatedSystems += $System } - end { return $UpdatedSystems - } - -} +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index 397bcf38b..d8ce331c7 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -187,7 +187,7 @@ Function New-JCUser () { begin { Write-Debug 'Verifying JCAPI Key' - if ([System.String]::IsNullOrEmpty($JCAPIKEY)) { Connect-JConline } + if ([System.String]::IsNullOrEmpty($JCAPIKEY)) { Connect-JCOnline } $hdrs = @{ @@ -298,79 +298,7 @@ Function New-JCUser () { # If manager field is null, skip continue } else { - # First check if manager returns valid user with id - # Regex match a userid - $regexPattern = [Regex]'^[a-z0-9]{24}$' - 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 = @{ - 'and' = @( - @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'id' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $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 - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'email' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } - } catch { - # search the username in the search endpoint - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } + $managerValue = Convert-JCUserToID -UserIdentifier $param.Value if ($managerValue) { $body.add($param.Key, $managerValue) } else { diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 56249f6a8..cdb28df47 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -561,83 +561,11 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # Get the manager using manager username instead of userId if ("manager" -eq $param.Key) { - if ([System.String]::isNullOrEmpty($param.value)) { - $managerValue = $null + if ($param.Value -eq $null -or $param.Value -eq "") { + $body.add($param.Key, $null) + continue } else { - # First check if manager returns valid user with id - # Regex match a userid - $regexPattern = [Regex]'^[a-z0-9]{24}$' - 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 = @{ - 'and' = @( - @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'id' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $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 for manager using email - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'email' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } - } catch { - # search the username in the search endpoint - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } + $managerValue = Convert-JCUserToID -UserIdentifier $param.Value if ($managerValue) { $body.add($param.Key, $managerValue) } else { @@ -732,83 +660,11 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # Get the manager using manager username instead of userId if ("manager" -eq $param.Key) { - if ([System.String]::isNullOrEmpty($param.value)) { - $managerValue = $null + if ($param.Value -eq $null -or $param.Value -eq "") { + $body.add($param.Key, $null) + continue } else { - # First check if manager returns valid user with id - # Regex match a userid - $regexPattern = [Regex]'^[a-z0-9]{24}$' - 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 = @{ - 'and' = @( - @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'id' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $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 for manager using email - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'email' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } - } catch { - # search the username in the search endpoint - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } + $managerValue = Convert-JCUserToID -UserIdentifier $param.Value if ($managerValue) { $body.add($param.Key, $managerValue) } else { @@ -972,84 +828,11 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # Get the manager using manager username instead of userId if ("manager" -eq $param.Key) { - if ([System.String]::isNullOrEmpty($param.value)) { - $managerValue = $null + if ($param.Value -eq $null -or $param.Value -eq "") { + $body.add($param.Key, $null) + continue } else { - # First check if manager returns valid user with id - # Regex match a userid - $regexPattern = [Regex]'^[a-z0-9]{24}$' - 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 = @{ - 'and' = @( - @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'id' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $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 - Write-Debug "This is true" - # Search for manager using email - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'email' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } - } catch { - # search the username in the search endpoint - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } + $managerValue = Convert-JCUserToID -UserIdentifier $param.Value if ($managerValue) { $body.add($param.Key, $managerValue) } else { @@ -1165,84 +948,11 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline # Get the manager using manager username instead of userId if ("manager" -eq $param.Key) { - if ([System.String]::isNullOrEmpty($param.value)) { - $managerValue = $null + if ($param.Value -eq $null -or $param.Value -eq "") { + $body.add($param.Key, $null) + continue } else { - # First check if manager returns valid user with id - # Regex match a userid - $regexPattern = [Regex]'^[a-z0-9]{24}$' - 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 = @{ - 'and' = @( - @{'id' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'id' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $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 - Write-Debug "This is true" - # Search for manager using email - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'email' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'email' - } - $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 = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } - } catch { - # search the username in the search endpoint - $managerSearch = @{ - filter = @{ - 'and' = @( - @{'username' = @{'$regex' = "(?i)(`^$($param.Value)`$)" } } - ) - } - fields = 'username' - } - $managerResults = Search-JcSdkUser -Body:($managerSearch) - # Set managerValue from the matched username - $managerValue = $managerResults.id - } + $managerValue = Convert-JCUserToID -UserIdentifier $param.Value if ($managerValue) { $body.add($param.Key, $managerValue) } else { diff --git a/PowerShell/JumpCloud Module/Public/Utilities/CSV_Import/New-JCDeviceUpdateTemplate.ps1 b/PowerShell/JumpCloud Module/Public/Utilities/CSV_Import/New-JCDeviceUpdateTemplate.ps1 index ea855d11b..501fefd55 100644 --- a/PowerShell/JumpCloud Module/Public/Utilities/CSV_Import/New-JCDeviceUpdateTemplate.ps1 +++ b/PowerShell/JumpCloud Module/Public/Utilities/CSV_Import/New-JCDeviceUpdateTemplate.ps1 @@ -75,6 +75,7 @@ Function New-JCDeviceUpdateTemplate { allowMultiFactorAuthentication = $null allowPublicKeyAuthentication = $null systemInsights = $null + primarySystemUser = $null } $fileName = 'JCDeviceUpdateImport_' + $date + '.csv' @@ -97,7 +98,7 @@ Function New-JCDeviceUpdateTemplate { $CSV = [ordered]@{ DeviceID = $null displayname = $null - hostname = $null + hostname = $null } Write-Host "`nWould you like to populate this update template with all of your existing systems?" @@ -198,6 +199,19 @@ Function New-JCDeviceUpdateTemplate { elseif ($ConfirmSystemInsights -eq 'N') { } + Write-Host "`nWould you like to set a primary system user?" + + while ($ConfirmPrimarySystemUser -ne 'Y' -and $ConfirmPrimarySystemUser -ne 'N') { + $ConfirmPrimarySystemUser = Read-Host "Enter Y for Yes or N for No" + } + + if ($ConfirmPrimarySystemUser -eq 'Y') { + $CSV.add('primarySystemUser', $null) + } + + elseif ($ConfirmPrimarySystemUser -eq 'N') { + } + $CSVheader = New-Object psobject -Property $Csv if ($systems) { diff --git a/PowerShell/JumpCloud Module/Tests/ModuleValidation/ReturnProperties.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/ModuleValidation/ReturnProperties.Tests.ps1 index cfdf9b59b..93aeb496d 100644 --- a/PowerShell/JumpCloud Module/Tests/ModuleValidation/ReturnProperties.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/ModuleValidation/ReturnProperties.Tests.ps1 @@ -49,7 +49,7 @@ Describe -Tag:('ModuleValidation') 'Return Properties Checks' { $missing = $inSwaggerNotFunction | where-object { $_.InputObject -notin $functionHash[$item].ignoreList } # there should not be any missing items if ($missing.InputObject) { - Write-Warning "The folling properties are defined in swagger for the $item function but not the module, either add them to the function validate set or add them to the ignore list in this test" + Write-Warning "The following properties are defined in swagger for the $item function but not the module, either add them to the function validate set or add them to the ignore list in this test" Write-host $missing.InputObject } $missing.InputObject | should -BeNullOrEmpty diff --git a/PowerShell/JumpCloud Module/Tests/Private/NestedFunctions/Convert-JCUserToID.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Private/NestedFunctions/Convert-JCUserToID.Tests.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/PowerShell/JumpCloud Module/Tests/Private/Policies/New-UriList.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Private/Policies/New-UriList.Tests.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/PowerShell/JumpCloud Module/Tests/Public/Policies/New-JCPolicy.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Policies/New-JCPolicy.Tests.ps1 index e53437490..231138381 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Policies/New-JCPolicy.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Policies/New-JCPolicy.Tests.ps1 @@ -92,6 +92,68 @@ Describe -Tag:('JCPolicy') 'New-JCPolicy' { ($multipleValPolicy.values | Where-Object { $_.configFieldName -eq "PreviewType" }).value | Should -Be 0 # 0 is the value for Always on the dropdown ($multipleValPolicy.values | Where-Object { $_.configFieldName -eq "BadgesEnabled" }).value | Should -Be $true } + + # URIList Test + It 'Creates a new policy that tests Custom Windows MDM OMA URIList' { + $policyTemplate = $policyTemplates | Where-Object { $_.name -eq "custom_oma_uri_mdm_windows" } + $templateId = $policyTemplate.id + $policyValueList = New-Object System.Collections.ArrayList + # Define list Values: + $policyValue = [pscustomobject]@{ + # Should look like this: (@( @{format = "string"; uri = "aasdadsdas"; value = "5" }, @{format = "string"; uri = "b"; value = "test" }, @{format = "boolean"; uri = "c"; value = "true" } )) + 'format' = 'int' + 'uri' = "./Device/Vendor/MSFT/Registry/HKLM/Software/Policies/Microsoft/Windows/Control Panel/Desktop/ScreenSaveTimeOut" + 'value' = '600' + } + $policyValue2 = [pscustomobject]@{ + 'format' = 'boolean' + 'uri' = "./Device/Vendor/MSFT/Registry/HKLM/Software/Policies/Microsoft/Windows/Control Panel/Desktop/ScreenSaveActive" + 'value' = "true" + } + $policyValue3 = [pscustomobject]@{ + 'format' = 'string' + 'uri' = "./Device/Vendor/MSFT/Registry/HKLM/Software/Policies/Microsoft/Windows/Control Panel/Desktop/ScreenSaveActive" + 'value' = "testString" + } + $policyValue4 = [pscustomobject]@{ + 'format' = 'float' + 'uri' = "./Device/Vendor/MSFT/Registry/HKLM/Software/Policies/Microsoft/Windows/Control Panel/Desktop/ScreenSaveActive" + 'value' = "2.5" + } + $policyValue5 = [pscustomobject]@{ + 'format' = 'xml' + 'uri' = "./Device/Vendor/MSFT/Registry/HKLM/Software/Policies/Microsoft/Windows/Control Panel/Desktop/ScreenSaveActive" + 'value' = "Test" + } + $policyValue6 = [pscustomobject]@{ + 'format' = 'base64' + 'uri' = "./Device/Vendor/MSFT/Registry/HKLM/Software/Policies/Microsoft/Windows/Control Panel/Desktop/ScreenSaveActive" + 'value' = "VGhpcyBpcyBhIHRlc3Q=" + } + # add values to list + $policyValueList.add($policyValue) | Out-Null # int type + $policyValueList.add($policyValue2) | Out-Null # boolean type + $policyValueList.Add($policyValue3) | Out-Null # string type + $policyValueList.Add($policyValue4) | Out-Null # float type + $policyValueList.Add($policyValue5) | Out-Null # xml type + $policyValueList.Add($policyValue6) | Out-Null # base64 type + + $uriListPolicy = New-JCPolicy -Name "Pester - URIList Test" -templateID $templateId -uriList $policyValueList + # Should not be null + $uriListPolicy.values.value.count | Should -Be 6 + $uriListPolicy.values.value[0].format | Should -Be "int" + $uriListPolicy.values.value[0].value | Should -Be "600" + $uriListPolicy.values.value[1].format | Should -Be "bool" + $uriListPolicy.values.value[1].value | Should -Be "true" + $uriListPolicy.values.value[2].format | Should -Be "chr" + $uriListPolicy.values.value[2].value | Should -Be "testString" + $uriListPolicy.values.value[3].format | Should -Be "float" + $uriListPolicy.values.value[3].value | Should -Be "2.5" + $uriListPolicy.values.value[4].format | Should -Be "xml" + $uriListPolicy.values.value[4].value | Should -Be "Test" + $uriListPolicy.values.value[5].format | Should -Be "b64" + $uriListPolicy.values.value[5].value | Should -Be "VGhpcyBpcyBhIHRlc3Q=" + } } Context 'Creates policies using the value parameters' { @@ -276,6 +338,128 @@ Describe -Tag:('JCPolicy') 'New-JCPolicy' { { New-JCPolicy -templateID $registryTemplate.id -customRegTable $policyValueList -Name "Pester - Registry Validation $(new-randomString -NumberOfChars 8)" } | Should -Throw } } + + # URIList Tests + Context 'New-JCPolicy should create a new policy using the URIList parameter' { + It 'New-JCPolicy creates a new policy using the URIList parameter successfully' { + $policyTemplate = $policyTemplates | Where-Object { $_.name -eq "custom_oma_uri_mdm_windows" } + $templateId = $policyTemplate.id + $uriList = @( + @{ format = "string"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage"; value = "Test" }, + @{ format = "int"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage"; value = "555" }, + @{ format = "boolean"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage"; value = "true" }, + @{ format = "float"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage"; value = "2.5" } + @{ format = "xml"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage"; value = "Test" }, + @{ format = "base64"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage"; value = "VGhpcyBpcyBhIHRlc3Q=" } + ) + $uriListPolicy = New-JCPolicy -Name "Pester - URIList1" -templateID $templateId -uriList $uriList + # Should not be null + $uriListPolicy.values.value.count | Should -Be 6 + $uriListPolicy.values.value[0].format | Should -Be "chr" + $uriListPolicy.values.value[0].value | Should -Be "Test" + $uriListPolicy.values.value[1].format | Should -Be "int" + $uriListPolicy.values.value[1].value | Should -Be "555" + $uriListPolicy.values.value[2].format | Should -Be "bool" + $uriListPolicy.values.value[2].value | Should -Be "true" + $uriListPolicy.values.value[3].format | Should -Be "float" + $uriListPolicy.values.value[3].value | Should -Be "2.5" + $uriListPolicy.values.value[4].format | Should -Be "xml" + $uriListPolicy.values.value[4].value | Should -Be "Test" + $uriListPolicy.values.value[5].format | Should -Be "b64" + $uriListPolicy.values.value[5].value | Should -Be "VGhpcyBpcyBhIHRlc3Q=" + + # Cleanup + $uriListPolicy = Get-JCPolicy | Where-Object { $_.Name -like "Pester - URIList*" } + $uriListPolicy | ForEach-Object { Remove-JcSdkPolicy -Id $_.id } + } + + It 'New-JCPolicy creates a new policy using the URIList parameter with invalid formats for each format' { + $policyTemplate = $policyTemplates | Where-Object { $_.name -eq "custom_oma_uri_mdm_windows" } + $templateId = $policyTemplate.id + + { New-JCPolicy -Name "Pester - URIList1" -templateID $templateId -uriList @(@{format = "string"; uri = "Test"; value = "" }) } | Should -Throw + { New-JCPolicy -Name "Pester - URIList2" -templateID $templateId -uriList @(@{format = "int"; uri = "Test"; value = "invalid" }) } | Should -Throw + { New-JCPolicy -Name "Pester - URIList3" -templateID $templateId -uriList @(@{format = "boolean"; uri = "Test"; value = "invalid" }) } | Should -Throw + { New-JCPolicy -Name "Pester - URIList4" -templateID $templateId -uriList @(@{format = "float"; uri = "Test"; value = "invalid" }) } | Should -Throw + { New-JCPolicy -Name "Pester - URIList5" -templateID $templateId -uriList @(@{format = "xml"; uri = "Test"; value = "invalid" }) } | Should -Throw + { New-JCPolicy -Name "Pester - URIList6" -templateID $templateId -uriList @(@{format = "base64"; uri = "Test"; value = "invalid" }) } | Should -Throw + # Cleanup + $uriListPolicy = Get-JCPolicy | Where-Object { $_.Name -like "Pester - URIList*" } + $uriListPolicy | ForEach-Object { Remove-JcSdkPolicy -Id $_.id } + + } + + It 'Handles invalid value - base64' { + $policyTemplate = $policyTemplates | Where-Object { $_.name -eq "custom_oma_uri_mdm_windows" } + $templateId = $policyTemplate.id + $invalidUriList = @( + @{ uri = "test"; format = "base64"; value = "invalid" } + ) + { New-JCPolicy -templateID $templateId -Name "Invalid Base64 Format Policy" -uriList $invalidUriList } | Should -Throw + } + + It 'Handles invalid value - xml' { + $policyTemplate = $policyTemplates | Where-Object { $_.name -eq "custom_oma_uri_mdm_windows" } + $templateId = $policyTemplate.id + $invalidUriList = @( + @{ uri = "test"; format = "xml"; value = "test data" + $setPolicy.values.value[5].value | Should -Be "SGVsbG8gV29ybGQh" + } + } + + Context 'Set-JCPolicy - Invalid Values' { + # Assuming $newPolicy is a valid policy object obtained from New-JCPolicy + BeforeEach { + $policyTemplate = $policyTemplates | Where-Object { $_.name -eq "custom_oma_uri_mdm_windows" } + $templateId = $policyTemplate.id + $uriList = @( + @{ uri = "a"; format = "int"; value = 2 } + ) + $newPolicy = New-JCPolicy -templateID $templateId -Name "Base Policy for Set Tests" -uriList $uriList + } + + It 'Handles invalid value in uriList - int' { + $invalidUriList = @( + @{ uri = "a"; format = "int"; value = "invalid" } + ) + { Set-JCPolicy -PolicyID $newPolicy.id -uriList $invalidUriList } | Should -Throw + } + + It 'Handles invalid value in uriList - string' { + $invalidUriList = @( + @{ uri = "a"; format = "string"; value = $null } #Null should be valid, so this test is changed. + ) + { Set-JCPolicy -PolicyID $newPolicy.id -uriList $invalidUriList } | Should -Throw + } + + It 'Handles invalid value in uriList - boolean' { + $invalidUriList = @( + @{ uri = "a"; format = "boolean"; value = "invalid" } + ) + { Set-JCPolicy -PolicyID $newPolicy.id -uriList $invalidUriList } | Should -Throw + } + + It 'Handles invalid value in uriList - float' { + $invalidUriList = @( + @{ uri = "a"; format = "float"; value = "invalid" } + ) + { Set-JCPolicy -PolicyID $newPolicy.id -uriList $invalidUriList } | Should -Throw + } + + It 'Handles invalid value in uriList - xml' { + $invalidUriList = @( + @{ uri = "a"; format = "xml"; value = " organization os osFamily + primarySystemUser provisionMetadata + remoteAssistAgentVersion remoteIP serialNumber serviceAccountState @@ -20489,6 +20491,18 @@ PS C:\> Set-JCPolicy -PolicyName "macOS - Login Window Policy" -Values $poli None + + primarySystemUser + + A string value indicating a JumpCloud users email, username or userID. This will add the user to the device associations + + System.Object + + System.Object + + + None + systemInsights @@ -20577,6 +20591,18 @@ PS C:\> Set-JCPolicy -PolicyName "macOS - Login Window Policy" -Values $poli None + + primarySystemUser + + A string value indicating a JumpCloud users email, username or userID. This will add the user to the device associations + + System.Object + + System.Object + + + None + SystemID diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 6ba8e34d7..ea634df93 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,6 +1,29 @@ +## 2.18.0 + +Release Date: April 11, 2025 + +#### RELEASE NOTES + +``` +This release adds support for Windows MDM OMA Custom policy (Custom MDM (OMA-URI)) with New/Set-JCPolicy +Introduces the primarySystemUser parameter to Set-JCSystem and Update-JCDeviceFromCSV functions. This parameter will allow you associate a user to the specified device + +``` + +#### FEATURES: +- Introduces support for passing list of objects (uriList) for Custom MDM (OMA-URI) policy with New/Set-JCPolicy + - Dynamic param added `-uriList` + - Menu for `Set-JCPolicy` to edit uriList - create/update/add/remove +* Added the primarySystemUser parameter to Set-JCSystem +* Update-JCDeviceFromCSV supports the primarySystemUser param that was added to Set-JCSystem + +#### BUG FIXES: + +* Added an Alias of GroupID to the ByID parameter for Get-JCUserGroupMember + ## 2.17.0 -Release Date: January 3, 2025 +Release Date: January 30, 2025 #### RELEASE NOTES From 91fe783f0b651fe623776e24ef0ef84277dd35e7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 09:57:01 -0700 Subject: [PATCH 03/60] test nuget --- .github/workflows/powershell-module-ci.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index d0984ae9a..93e3f4bf2 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -74,6 +74,19 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies + - name: Install System Dependencies + if: steps.cacher.outputs.cache-hit != 'true' + shell: pwsh + run: | + Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force + # Check if NuGet is installed + if (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { + Write-Host ('[status]Installing package provider NuGet'); + Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force + # Test if nuget is working ran + } else { + Write-Host ('[status]Package provider NuGet already installed'); + } - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh From eee0536533c8b4c42f0c2e70ab6bbeec32ced51f Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 09:59:17 -0700 Subject: [PATCH 04/60] dates --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleChangelog.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index a2e806363..c747cf5a9 100644 --- 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/11/2025 +# Generated on: 4/16/2025 # @{ diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index ea634df93..7b94e8f99 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,6 +1,6 @@ ## 2.18.0 -Release Date: April 11, 2025 +Release Date: April 16, 2025 #### RELEASE NOTES From 647c06d2d87af6ed35dd3cfe4033a314cc9afbb3 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 10:14:17 -0700 Subject: [PATCH 05/60] nuget test --- .github/workflows/powershell-module-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 93e3f4bf2..50a79178f 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -78,7 +78,12 @@ jobs: if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh run: | + # Update PowerShellGet first + Install-Module -Name PowerShellGet -Force -AllowClobber -Repository PSGallery + + # Then try to install NuGet Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force + # Check if NuGet is installed if (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); From 17e31be078be3f95d0b4b719321d3981f202834d Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 10:43:55 -0700 Subject: [PATCH 06/60] nuget action --- .github/workflows/powershell-module-ci.yml | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 50a79178f..a659ea971 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -74,24 +74,17 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies + - uses: nuget/setup-nuget@v2 - name: Install System Dependencies - if: steps.cacher.outputs.cache-hit != 'true' + # Add your system dependencies installation commands here shell: pwsh run: | - # Update PowerShellGet first - Install-Module -Name PowerShellGet -Force -AllowClobber -Repository PSGallery - - # Then try to install NuGet - Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force - - # Check if NuGet is installed - if (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { + # Check if nuget is installed + if (-not (Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue)) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force - # Test if nuget is working ran - } else { - Write-Host ('[status]Package provider NuGet already installed'); } + - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh From ccf907a16224cc48f157128d22c8a59cf68fc79c Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 10:49:13 -0700 Subject: [PATCH 07/60] test --- .github/workflows/powershell-module-ci.yml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index a659ea971..96788bc81 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -79,11 +79,9 @@ jobs: # Add your system dependencies installation commands here shell: pwsh run: | - # Check if nuget is installed - if (-not (Get-PackageProvider -Name NuGet -ListAvailable -ErrorAction SilentlyContinue)) { - Write-Host ('[status]Installing package provider NuGet'); - Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force - } + # Test nuget: + nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' From 801457af222123b124425031945c59074600f598 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 11:11:24 -0700 Subject: [PATCH 08/60] test dotnet nuget --- .github/workflows/powershell-module-ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 96788bc81..77338e567 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -74,14 +74,11 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies - - uses: nuget/setup-nuget@v2 - name: Install System Dependencies # Add your system dependencies installation commands here shell: pwsh run: | - # Test nuget: - nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - + dotnet nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' From 41ea840c889e293159876624aedc35c2ba9cff24 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 11:15:59 -0700 Subject: [PATCH 09/60] test dotnet --- .github/workflows/powershell-module-ci.yml | 2 +- .github/workflows/release-workflow.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 77338e567..0ec199f00 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -78,7 +78,7 @@ jobs: # Add your system dependencies installation commands here shell: pwsh run: | - dotnet nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + dotnet pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 0ffa79b9a..8a3b39e03 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -106,7 +106,7 @@ jobs: - name: Pack nuspec shell: pwsh run: | - nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + dotnet nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - name: Validate NuPkg File shell: pwsh run: | From f0f6a13fb959f132dbd3068da1db5b4e57f48537 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 11:29:59 -0700 Subject: [PATCH 10/60] dotnet --- .github/workflows/powershell-module-ci.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 0ec199f00..3095f4efc 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -74,11 +74,16 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies + - name: Build Nuspec + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery - name: Install System Dependencies # Add your system dependencies installation commands here shell: pwsh run: | - dotnet pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + dotnet pack --nuspec "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -p:NoWarn=NU5111,NU5110 - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' From f54252666c26b637fa93b0ec874998d72d0ec340 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 11:33:12 -0700 Subject: [PATCH 11/60] test --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 3095f4efc..7c092b16d 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -83,7 +83,7 @@ jobs: # Add your system dependencies installation commands here shell: pwsh run: | - dotnet pack --nuspec "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -p:NoWarn=NU5111,NU5110 + dotnet pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -p:NoWarn=NU5111,NU5110 - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' From 6f58cb4f06424680e094ea32f85a5ed30600d369 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 11:35:41 -0700 Subject: [PATCH 12/60] nuspec --- .github/workflows/powershell-module-ci.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 7c092b16d..d17ac9903 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -83,6 +83,7 @@ jobs: # Add your system dependencies installation commands here shell: pwsh run: | + # Install System Dependencies dotnet pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -p:NoWarn=NU5111,NU5110 - name: Install dependencies From 9959d714eeb170ca539b5c8830786a02de1ef27f Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 11:50:25 -0700 Subject: [PATCH 13/60] nowarn --- .github/workflows/powershell-module-ci.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index d17ac9903..c160556c1 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -83,8 +83,7 @@ jobs: # Add your system dependencies installation commands here shell: pwsh run: | - # Install System Dependencies - dotnet pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -p:NoWarn=NU5111,NU5110 + dotnet pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -p:NoWarn=NU5111;NU5110 - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' From e39cc2c3b8bea9a14740d0675f3fa2bbff1863de Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 13:02:15 -0700 Subject: [PATCH 14/60] nuget install --- .github/workflows/powershell-module-ci.yml | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index c160556c1..0151b8110 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -79,12 +79,27 @@ jobs: run: | $ErrorActionPreference = 'Stop' . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery + - name: Install System Dependencies - # Add your system dependencies installation commands here - shell: pwsh + if: steps.cacher.outputs.cache-hit != 'true' run: | - dotnet pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -p:NoWarn=NU5111;NU5110 - + sudo apt install ca-certificates gnupg + sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list + sudo apt update + sudo apt-get install -y mono-complete + curl -sSL https://dist.nuget.org/win-x86-commandline/v6.8.0/nuget.exe -o /usr/local/bin/nuget + chmod +x /usr/local/bin/nuget + source ~/.bashrc + # Create as alias for nuget + alias nuget="mono /usr/local/bin/nuget.exe" + # Verify that nuget is installed + if ! command -v nuget &> /dev/null + nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + then + echo "nuget could not be found" + exit 1 + fi - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh From adbe06eceac4d7e7193bdb5f0688ee245840d301 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 13:05:03 -0700 Subject: [PATCH 15/60] install mono and nuget manually --- .github/workflows/powershell-module-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 0151b8110..135bbceea 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -81,7 +81,6 @@ jobs: . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery - name: Install System Dependencies - if: steps.cacher.outputs.cache-hit != 'true' run: | sudo apt install ca-certificates gnupg sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF From f61af3960399ff66450c88fd74e8c064057e7326 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 13:13:10 -0700 Subject: [PATCH 16/60] nuget --- .github/workflows/powershell-module-ci.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 135bbceea..680948470 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -87,10 +87,11 @@ jobs: echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update sudo apt-get install -y mono-complete - curl -sSL https://dist.nuget.org/win-x86-commandline/v6.8.0/nuget.exe -o /usr/local/bin/nuget - chmod +x /usr/local/bin/nuget - source ~/.bashrc + # Download the latest stable `nuget.exe` to `/usr/local/bin` + sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe + echo 'alias nuget="mono /usr/local/bin/nuget.exe"' >> ~/.bashrc # Create as alias for nuget + source ~/.bashrc alias nuget="mono /usr/local/bin/nuget.exe" # Verify that nuget is installed if ! command -v nuget &> /dev/null From 648d5475d4e167bb438dbe9af067ba4769c63d5f Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 13:38:41 -0700 Subject: [PATCH 17/60] provider --- .github/workflows/powershell-module-ci.yml | 27 ++++++++-------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 680948470..620ad7742 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -81,25 +81,18 @@ jobs: . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery - name: Install System Dependencies + shell: pwsh run: | - sudo apt install ca-certificates gnupg - sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list - sudo apt update - sudo apt-get install -y mono-complete - # Download the latest stable `nuget.exe` to `/usr/local/bin` - sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe - echo 'alias nuget="mono /usr/local/bin/nuget.exe"' >> ~/.bashrc - # Create as alias for nuget - source ~/.bashrc - alias nuget="mono /usr/local/bin/nuget.exe" - # Verify that nuget is installed - if ! command -v nuget &> /dev/null + # Install packageprovider + + # Get packageprovider list + $PackageProviders = Get-PackageProvider -ListAvailable + Write-Host ('[status]Package Providers: $PackageProviders') + Install-Module PowerShellGet -Force + Get-PackageProvider | Where-Object {$_.Name -eq "NuGet"} | Install-PackageProvider + nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - then - echo "nuget could not be found" - exit 1 - fi + - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh From 532454b5c75a03d996153fc72020396623e8e644 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 13:42:33 -0700 Subject: [PATCH 18/60] force install nuget --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 620ad7742..718c45c2c 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -89,7 +89,7 @@ jobs: $PackageProviders = Get-PackageProvider -ListAvailable Write-Host ('[status]Package Providers: $PackageProviders') Install-Module PowerShellGet -Force - Get-PackageProvider | Where-Object {$_.Name -eq "NuGet"} | Install-PackageProvider + Get-PackageProvider | Where-Object {$_.Name -eq "NuGet"} | Install-PackageProvider -force nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 From d62f8972e68a6af8025c3c92235507529349f94a Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 14:01:59 -0700 Subject: [PATCH 19/60] test setup --- .github/workflows/powershell-module-ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 718c45c2c..47314a07d 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -79,17 +79,15 @@ jobs: run: | $ErrorActionPreference = 'Stop' . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery - + - uses: nuget/setup-nuget@v2 - name: Install System Dependencies - shell: pwsh run: | - # Install packageprovider + sudo apt install ca-certificates gnupg + sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list + sudo apt update + sudo apt install mono-devel - # Get packageprovider list - $PackageProviders = Get-PackageProvider -ListAvailable - Write-Host ('[status]Package Providers: $PackageProviders') - Install-Module PowerShellGet -Force - Get-PackageProvider | Where-Object {$_.Name -eq "NuGet"} | Install-PackageProvider -force nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 From 363edd8e5054fb4810c483bdc59ab437524966ca Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 14:21:07 -0700 Subject: [PATCH 20/60] nuget --- .github/workflows/powershell-module-ci.yml | 10 +--------- .github/workflows/release-workflow.yml | 10 +++++++--- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 47314a07d..9f2068318 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -74,23 +74,15 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies - - name: Build Nuspec - shell: pwsh - run: | - $ErrorActionPreference = 'Stop' - . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery - uses: nuget/setup-nuget@v2 - name: Install System Dependencies + if: steps.cacher.outputs.cache-hit != 'true' run: | sudo apt install ca-certificates gnupg sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update sudo apt install mono-devel - - - nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 8a3b39e03..85d49d9c3 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -54,11 +54,15 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies + - uses: nuget/setup-nuget@v2 - name: Install System Dependencies if: steps.cacher.outputs.cache-hit != 'true' - shell: pwsh run: | - Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force + sudo apt install ca-certificates gnupg + sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF + echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list + sudo apt update + sudo apt install mono-devel - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh @@ -106,7 +110,7 @@ jobs: - name: Pack nuspec shell: pwsh run: | - dotnet nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - name: Validate NuPkg File shell: pwsh run: | From 73559f66d48e912726779376c80a54b9fa1d92d7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 14:45:27 -0700 Subject: [PATCH 21/60] extra validation --- .github/workflows/powershell-module-ci.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 9f2068318..3e479b6d4 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -83,6 +83,12 @@ jobs: echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update sudo apt install mono-devel + + if ! command -v nuget >/dev/null 2>&1; then + echo "Error: NuGet is not installed." + exit 1 + fi + echo "NuGet is installed. Continuing with the tests..." - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh From 734f67969a014348b31222178fc24ac3cc09564e Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Wed, 16 Apr 2025 14:52:39 -0700 Subject: [PATCH 22/60] release nuget --- .github/workflows/release-workflow.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index 85d49d9c3..ac2a6909a 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -63,6 +63,12 @@ jobs: echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list sudo apt update sudo apt install mono-devel + + if ! command -v nuget >/dev/null 2>&1; then + echo "Error: NuGet is not installed." + exit 1 + fi + echo "NuGet is installed. Continuing with the tests..." - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh From e4b0d1723cb8832c2492c4be0d256a502991a0eb Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 09:50:27 -0700 Subject: [PATCH 23/60] test nuspec pack before adding to release workflow --- .github/workflows/powershell-module-ci.yml | 42 ++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 3e479b6d4..200c53963 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -64,7 +64,7 @@ jobs: $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') Setup-Build-Dependancies: needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] - runs-on: ubuntu-latest + runs-on: windows-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -127,7 +127,45 @@ jobs: } } } - +Build-Nuspec-Nupkg: + needs: Setup-Build-Dependancies + runs-on: windows-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - name: Build Nuspec + shell: pwsh + run: | + $ErrorActionPreference = 'Stop' + . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery + - name: Pack nuspec + shell: pwsh + run: | + nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + - name: Validate NuPkg File + shell: pwsh + run: | + $NupkgPathDirectory = (Get-ChildItem -Path:("./*.nupkg")).Directory + $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName + Write-Host "NuPkg Path: $nupkgPath" + mkdir $NupkgPathDirectory/nupkg_module + unzip $nupkgPath -d $NupkgPathDirectory/nupkg_module + $moduleRootFiles = Get-ChildItem -File -Path:("$NupkgPathDirectory/nupkg_module") + $moduleRootDirectories = Get-ChildItem -Directory -Path:("$NupkgPathDirectory/nupkg_module") + Write-Host "Module Files:\n$moduleRootFiles" + Write-Host "Module Directories:\n$moduleRootDirectories" + # Validate that the nuspec directory contains a Public/ Private directory + "Private" | should -bein $moduleRootDirectories.name + "Public" | should -bein $moduleRootDirectories.name + - name: Upload Nupkg + uses: ./.github/actions/upload-secure-artifact + with: + name: jumpcloud-module-nupkg + path: /home/runner/work/support/support/JumpCloud.*.nupkg + retention-days: 1 Validate-Module: needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] runs-on: ubuntu-latest From e63422d8562fb7eb15eb81a76df1358650d780dd Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 09:51:35 -0700 Subject: [PATCH 24/60] test nuspec pack before adding to release workflow --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 200c53963..27c809ea9 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -127,7 +127,7 @@ jobs: } } } -Build-Nuspec-Nupkg: + Build-Nuspec-Nupkg: needs: Setup-Build-Dependancies runs-on: windows-latest steps: From dfa4b2076c235f49842ddd6148abd104ef2aa6b3 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 09:54:55 -0700 Subject: [PATCH 25/60] remove mono dependency --- .github/workflows/powershell-module-ci.yml | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 27c809ea9..97310c0cb 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -74,21 +74,6 @@ jobs: with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies - - uses: nuget/setup-nuget@v2 - - name: Install System Dependencies - if: steps.cacher.outputs.cache-hit != 'true' - run: | - sudo apt install ca-certificates gnupg - sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list - sudo apt update - sudo apt install mono-devel - - if ! command -v nuget >/dev/null 2>&1; then - echo "Error: NuGet is not installed." - exit 1 - fi - echo "NuGet is installed. Continuing with the tests..." - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh From 0dcb4dc22736618509070da5549f7b88183fc515 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 09:59:07 -0700 Subject: [PATCH 26/60] test --- .github/workflows/powershell-module-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 97310c0cb..32d5de0c3 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -82,8 +82,6 @@ jobs: PESTER_ORGID: ${{ secrets.PESTER_ORGID }} PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - Set-PSRepository PSGallery -InstallationPolicy Trusted - If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force From 568ff792d98ef291615a675487e8f8b2408e180e Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:02:22 -0700 Subject: [PATCH 27/60] test --- .github/workflows/powershell-module-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 32d5de0c3..ad128a372 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -64,7 +64,7 @@ jobs: $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') Setup-Build-Dependancies: needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] - runs-on: windows-latest + runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -82,6 +82,7 @@ jobs: PESTER_ORGID: ${{ secrets.PESTER_ORGID }} PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force From 528428dbfab140a6c4fb327485e33e58426142a7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:12:50 -0700 Subject: [PATCH 28/60] validate nupkg --- .github/workflows/powershell-module-ci.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index ad128a372..964912bf6 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -144,12 +144,6 @@ jobs: # Validate that the nuspec directory contains a Public/ Private directory "Private" | should -bein $moduleRootDirectories.name "Public" | should -bein $moduleRootDirectories.name - - name: Upload Nupkg - uses: ./.github/actions/upload-secure-artifact - with: - name: jumpcloud-module-nupkg - path: /home/runner/work/support/support/JumpCloud.*.nupkg - retention-days: 1 Validate-Module: needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] runs-on: ubuntu-latest From e0d6cfaa07d60c85853aefe717de81d3cba09e01 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:23:51 -0700 Subject: [PATCH 29/60] aws error fix --- .github/workflows/powershell-module-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 964912bf6..d03c66777 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -64,7 +64,7 @@ jobs: $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') Setup-Build-Dependancies: needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] - runs-on: ubuntu-latest + runs-on: windows-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -104,7 +104,9 @@ jobs: foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") - if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ + if ($RequireModule -eq "AWS.Tools.Common" -or $RequireModule -eq "AWS.Tools.CodeArtifact") { + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force + } elseif ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force From 9e471f7494d68d94d0173f0bbb0263dae9a76028 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:28:48 -0700 Subject: [PATCH 30/60] override aws install --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index d03c66777..36c2fef2c 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -105,7 +105,7 @@ jobs: If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") if ($RequireModule -eq "AWS.Tools.Common" -or $RequireModule -eq "AWS.Tools.CodeArtifact") { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force -AllowClobber } elseif ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { From 6e3c0c99724d8e2672b2a3f04480fcf5a4180020 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:36:00 -0700 Subject: [PATCH 31/60] test --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 36c2fef2c..78851737f 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -105,7 +105,7 @@ jobs: If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") if ($RequireModule -eq "AWS.Tools.Common" -or $RequireModule -eq "AWS.Tools.CodeArtifact") { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force -AllowClobber + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -AllowClobber } elseif ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { From c9e20ae718d3f4fd4c9f97ab0e80ef58b1e36e1b Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:40:03 -0700 Subject: [PATCH 32/60] clobber --- .github/workflows/powershell-module-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 78851737f..8b31b5e4b 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -104,12 +104,10 @@ jobs: foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") - if ($RequireModule -eq "AWS.Tools.Common" -or $RequireModule -eq "AWS.Tools.CodeArtifact") { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -AllowClobber - } elseif ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ + if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -AllowClobber } } } From 1d2274b2ce21a0bda77917c2b75bb43be41621f7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:45:11 -0700 Subject: [PATCH 33/60] test --- .github/workflows/powershell-module-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 8b31b5e4b..4e57710a4 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -104,10 +104,12 @@ jobs: foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") - if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ + if ($RequireModule -eq "AWS.Tools.Common" -or $RequireModule -eq "AWS.Tools.CodeArtifact" -or $RequireModule -eq "PowerShellGet") { + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -AllowClobber + } elseif ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -AllowClobber + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force } } } From 7d3a878501bece4eddf47d445193ed283bc5664d Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 10:50:21 -0700 Subject: [PATCH 34/60] dependency test on windows --- .github/workflows/powershell-module-ci.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 4e57710a4..8b31b5e4b 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -104,12 +104,10 @@ jobs: foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") - if ($RequireModule -eq "AWS.Tools.Common" -or $RequireModule -eq "AWS.Tools.CodeArtifact" -or $RequireModule -eq "PowerShellGet") { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -AllowClobber - } elseif ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ + if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -AllowClobber } } } From e4a86ebb0e6c253d8ae40eb9a4706ddd2c4fcc78 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 11:05:52 -0700 Subject: [PATCH 35/60] dates --- .github/workflows/powershell-module-ci.yml | 16 ++++++++-------- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleChangelog.md | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 8b31b5e4b..56d161700 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -62,7 +62,7 @@ jobs: run: | # validate release type variables $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') - Setup-Build-Dependancies: + Setup-Build-Dependencies: needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] runs-on: windows-latest timeout-minutes: 10 @@ -70,11 +70,11 @@ jobs: - uses: actions/checkout@v4 - name: Setup PowerShell Module Cache id: cacher - uses: actions/cache@v3 + uses: actions/cache@v4 with: - path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies - - name: Install dependencies + path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' + key: PS-Dependencies + - name: Install Dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh env: @@ -112,14 +112,14 @@ jobs: } } Build-Nuspec-Nupkg: - needs: Setup-Build-Dependancies + needs: Setup-Build-Dependencies runs-on: windows-latest steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies + key: PS-Dependencies - name: Build Nuspec shell: pwsh run: | diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index c747cf5a9..d5d03f0c9 100644 --- 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/16/2025 +# Generated on: 4/17/2025 # @{ diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 7b94e8f99..b0683c286 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,6 +1,6 @@ ## 2.18.0 -Release Date: April 16, 2025 +Release Date: April 17, 2025 #### RELEASE NOTES From fee148f3b8c5cb1f5375462ab8c6f3a1c6d99f08 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 11:14:24 -0700 Subject: [PATCH 36/60] dependency --- .github/workflows/powershell-module-ci.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 56d161700..765afa293 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -145,7 +145,7 @@ jobs: "Private" | should -bein $moduleRootDirectories.name "Public" | should -bein $moduleRootDirectories.name Validate-Module: - needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] runs-on: ubuntu-latest timeout-minutes: 10 steps: @@ -164,7 +164,7 @@ jobs: run: | . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation Setup-Org: - needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] runs-on: ubuntu-latest name: Setup Org Upload Variable Artifact steps: @@ -196,7 +196,7 @@ jobs: name: jumpcloud-vars path: /home/runner/.local/share/powershell/Modules/PesterVariables.json Test-Module: - needs: ["Setup-Build-Dependancies", "Check-PR-Labels", "Setup-Org"] + needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Setup-Org"] runs-on: ubuntu-latest timeout-minutes: 75 strategy: @@ -245,7 +245,7 @@ jobs: # Invoke Pester . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery" Test-Module-MSP: - needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] runs-on: ubuntu-latest timeout-minutes: 20 steps: From 47aa91286d653e8161ddf155f4389a683e12f3c7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 11:32:09 -0700 Subject: [PATCH 37/60] validate --- .github/workflows/powershell-module-ci.yml | 79 +++++++++++----------- 1 file changed, 39 insertions(+), 40 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 765afa293..dd87f0cb8 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -63,8 +63,8 @@ jobs: # validate release type variables $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') Setup-Build-Dependencies: - needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] runs-on: windows-latest + needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -74,46 +74,64 @@ jobs: with: path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependencies - - name: Install Dependencies + - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh - env: - PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} - PESTER_ORGID: ${{ secrets.PESTER_ORGID }} - PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + Set-PSRepository PSGallery -InstallationPolicy Trusted + If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force } - + # define dependencies for this ci workflow: $PSDependencies = @{ 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } - 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } - 'PSScriptAnalyzer' = @{Repository = 'PSGallery'; RequiredVersion = '1.19.1' } + 'ps2exe' = @{Repository = 'PSGallery'; RequiredVersion = '1.0.13' } 'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } - 'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } - 'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} - 'powershell-yaml' = @{Repository = 'PSGallery'; RequiredVersion = '0.4.7'} + 'JumpCloud' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} } - foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { - Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") + $latestModule = find-module $RequiredModule + Write-Host "[status] latest module: $RequiredModule; latest version: $($latestModule.Version)" + Write-Host("[status] Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -Force } else { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -AllowClobber + if($RequiredModule -eq 'PowerShellGet'){ + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -allowClobber + } else { + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force + } } } } + Validate-Module: + needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + .github + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependencies + - env: + RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} + shell: pwsh + run: | + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation Build-Nuspec-Nupkg: - needs: Setup-Build-Dependencies runs-on: windows-latest + needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Validate-Module"] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -144,25 +162,6 @@ jobs: # Validate that the nuspec directory contains a Public/ Private directory "Private" | should -bein $moduleRootDirectories.name "Public" | should -bein $moduleRootDirectories.name - Validate-Module: - needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: ubuntu-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - PowerShell - .github - - uses: actions/cache@v3 - with: - path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies - - env: - RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} - shell: pwsh - run: | - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation Setup-Org: needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] runs-on: ubuntu-latest @@ -176,7 +175,7 @@ jobs: - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies + key: PS-Dependencies - name: Setup Org Variables shell: pwsh env: @@ -213,7 +212,7 @@ jobs: - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies + key: PS-Dependencies - uses: actions/download-artifact@v4 with: name: jumpcloud-vars @@ -257,7 +256,7 @@ jobs: - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies + key: PS-Dependencies - shell: pwsh env: PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} From a1aac082a9056b2b2b2f4407c3b788207df7ad91 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 11:41:29 -0700 Subject: [PATCH 38/60] module validation --- .github/workflows/powershell-module-ci.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index dd87f0cb8..2b4c771c5 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -87,12 +87,15 @@ jobs: # define dependencies for this ci workflow: $PSDependencies = @{ 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } - 'ps2exe' = @{Repository = 'PSGallery'; RequiredVersion = '1.0.13' } + 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } + 'PSScriptAnalyzer' = @{Repository = 'PSGallery'; RequiredVersion = '1.19.1' } 'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } + 'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } + 'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} - 'JumpCloud' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} + 'powershell-yaml' = @{Repository = 'PSGallery'; RequiredVersion = '0.4.7'} } foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { @@ -112,7 +115,7 @@ jobs: } Validate-Module: needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: ubuntu-latest + runs-on: windows-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -120,7 +123,7 @@ jobs: sparse-checkout: | PowerShell .github - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependencies From 21bbcf105692232705f792652a2e142697d39ddf Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 11:46:17 -0700 Subject: [PATCH 39/60] module validation --- .github/workflows/powershell-module-ci.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 2b4c771c5..ced0ed83a 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -125,13 +125,24 @@ jobs: .github - uses: actions/cache@v4 with: - path: "/home/runner/.local/share/powershell/Modules/" + path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependencies - env: RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} shell: pwsh run: | - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + # build before test + $installedModules = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\" + Write-Host "[status] InstalledModules:" + $installedModules + # Explicitly import required modules for powershell shell: + $requiredModules = ('ps2exe', 'JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2', 'JumpCloud') + foreach ($module in $requiredModules){ + $modulePSD1 = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\$module" -Recurse -filter "*.psd1" + Write-Host "[status] Importing: $module at path $($modulePSD1.fullname)" + Import-Module "$($modulePSD1.fullname)" -force + } + . "./jumpcloud-ADMU/Powershell/InvokePester.ps1" -ModuleValidation Build-Nuspec-Nupkg: runs-on: windows-latest needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Validate-Module"] From bcc5d9d8961ec0432e4dd4360c1b12bea1d45735 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 11:52:01 -0700 Subject: [PATCH 40/60] test --- .github/workflows/powershell-module-ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index ced0ed83a..29cc87b5c 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -99,17 +99,11 @@ jobs: } foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { - $latestModule = find-module $RequiredModule - Write-Host "[status] latest module: $RequiredModule; latest version: $($latestModule.Version)" - Write-Host("[status] Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") + Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -Force + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { - if($RequiredModule -eq 'PowerShellGet'){ - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -allowClobber - } else { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force - } + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -AllowClobber } } } From 81e6351956aec7a4b764a62495814b34b4c0d872 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:02:01 -0700 Subject: [PATCH 41/60] module validation --- .github/workflows/powershell-module-ci.yml | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 29cc87b5c..7061745a1 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -109,7 +109,7 @@ jobs: } Validate-Module: needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: windows-latest + runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -117,26 +117,15 @@ jobs: sparse-checkout: | PowerShell .github - - uses: actions/cache@v4 + - uses: actions/cache@v3 with: - path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' + path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependencies - env: RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} shell: pwsh run: | - # build before test - $installedModules = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\" - Write-Host "[status] InstalledModules:" - $installedModules - # Explicitly import required modules for powershell shell: - $requiredModules = ('ps2exe', 'JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2', 'JumpCloud') - foreach ($module in $requiredModules){ - $modulePSD1 = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\$module" -Recurse -filter "*.psd1" - Write-Host "[status] Importing: $module at path $($modulePSD1.fullname)" - Import-Module "$($modulePSD1.fullname)" -force - } - . "./jumpcloud-ADMU/Powershell/InvokePester.ps1" -ModuleValidation + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation Build-Nuspec-Nupkg: runs-on: windows-latest needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Validate-Module"] From 132ae084821b06207077b88452eb6e949a281bac Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:12:18 -0700 Subject: [PATCH 42/60] load jc --- .github/workflows/powershell-module-ci.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 7061745a1..9a0522761 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -109,7 +109,7 @@ jobs: } Validate-Module: needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: ubuntu-latest + runs-on: windows-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -117,15 +117,26 @@ jobs: sparse-checkout: | PowerShell .github - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: - path: "/home/runner/.local/share/powershell/Modules/" + path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependencies - env: RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} shell: pwsh run: | - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + # build before test + $installedModules = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\" + Write-Host "[status] InstalledModules:" + $installedModules + # Explicitly import required modules for powershell shell: + $requiredModules = ('ps2exe', 'JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2', 'JumpCloud') + foreach ($module in $requiredModules){ + $modulePSD1 = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\$module" -Recurse -filter "*.psd1" + Write-Host "[status] Importing: $module at path $($modulePSD1.Name)" + Import-Module "$($modulePSD1.Name)" -force -AllowClobber + } + . "./jumpcloud-ADMU/Powershell/InvokePester.ps1" -ModuleValidation Build-Nuspec-Nupkg: runs-on: windows-latest needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Validate-Module"] From d234289cbff914c3e00b4d6b2b89e6eca1249661 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:35:54 -0700 Subject: [PATCH 43/60] module install --- .github/workflows/powershell-module-ci.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 9a0522761..fc3dfdeda 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -132,9 +132,8 @@ jobs: # Explicitly import required modules for powershell shell: $requiredModules = ('ps2exe', 'JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2', 'JumpCloud') foreach ($module in $requiredModules){ - $modulePSD1 = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\$module" -Recurse -filter "*.psd1" - Write-Host "[status] Importing: $module at path $($modulePSD1.Name)" - Import-Module "$($modulePSD1.Name)" -force -AllowClobber + Write-Host "[status] Importing: $module at path $($module)" + Import-Module "$($module)" -force } . "./jumpcloud-ADMU/Powershell/InvokePester.ps1" -ModuleValidation Build-Nuspec-Nupkg: From 803d378459f457fd31308e3e980319678a32c511 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:43:02 -0700 Subject: [PATCH 44/60] update --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index fc3dfdeda..04c1e73ae 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -130,7 +130,7 @@ jobs: Write-Host "[status] InstalledModules:" $installedModules # Explicitly import required modules for powershell shell: - $requiredModules = ('ps2exe', 'JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2', 'JumpCloud') + $requiredModules = ('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2', 'JumpCloud') foreach ($module in $requiredModules){ Write-Host "[status] Importing: $module at path $($module)" Import-Module "$($module)" -force From ab09e1ecb728673ad42c0b6404dc5595c915dbb7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:45:30 -0700 Subject: [PATCH 45/60] import --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 04c1e73ae..af80a36b6 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -130,7 +130,7 @@ jobs: Write-Host "[status] InstalledModules:" $installedModules # Explicitly import required modules for powershell shell: - $requiredModules = ('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2', 'JumpCloud') + $requiredModules = ('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') foreach ($module in $requiredModules){ Write-Host "[status] Importing: $module at path $($module)" Import-Module "$($module)" -force From a9e14888a7590629553c5b9e65377ebe8de577c5 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:46:45 -0700 Subject: [PATCH 46/60] validation --- .github/workflows/powershell-module-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index af80a36b6..c373d32ed 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -129,11 +129,12 @@ jobs: $installedModules = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\" Write-Host "[status] InstalledModules:" $installedModules - # Explicitly import required modules for powershell shell: + # Explicitly import required modules for powershell shell validation: $requiredModules = ('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') foreach ($module in $requiredModules){ Write-Host "[status] Importing: $module at path $($module)" Import-Module "$($module)" -force + } . "./jumpcloud-ADMU/Powershell/InvokePester.ps1" -ModuleValidation Build-Nuspec-Nupkg: From 3515b4638bae1b15fc639b7600e64618fb5c8243 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:54:27 -0700 Subject: [PATCH 47/60] validate --- .github/workflows/powershell-module-ci.yml | 74 +++++++++------------- 1 file changed, 30 insertions(+), 44 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index c373d32ed..0a675a09c 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -43,7 +43,6 @@ jobs: $RELEASE_TYPE = $item } } - if ($typeCount -eq 1) { echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT } else { @@ -63,8 +62,8 @@ jobs: # validate release type variables $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') Setup-Build-Dependencies: - runs-on: windows-latest needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] + runs-on: windows-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 @@ -74,17 +73,19 @@ jobs: with: path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependencies - - name: Install dependencies + - name: Install Dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh + env: + PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - Set-PSRepository PSGallery -InstallationPolicy Trusted - + Set-PSRepository -Name PSGallery -InstallationPolicy Trusted If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force } - # define dependencies for this ci workflow: $PSDependencies = @{ 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } @@ -107,39 +108,9 @@ jobs: } } } - Validate-Module: - needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: windows-latest - timeout-minutes: 10 - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - PowerShell - .github - - uses: actions/cache@v4 - with: - path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' - key: PS-Dependencies - - env: - RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} - shell: pwsh - run: | - # build before test - $installedModules = Get-ChildItem "C:\Users\runneradmin\Documents\PowerShell\Modules\" - Write-Host "[status] InstalledModules:" - $installedModules - # Explicitly import required modules for powershell shell validation: - $requiredModules = ('JumpCloud.SDK.DirectoryInsights', 'JumpCloud.SDK.V1', 'JumpCloud.SDK.V2') - foreach ($module in $requiredModules){ - Write-Host "[status] Importing: $module at path $($module)" - Import-Module "$($module)" -force - - } - . "./jumpcloud-ADMU/Powershell/InvokePester.ps1" -ModuleValidation Build-Nuspec-Nupkg: + needs: Setup-Build-Dependencies runs-on: windows-latest - needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Validate-Module"] steps: - uses: actions/checkout@v4 - uses: actions/cache@v4 @@ -170,6 +141,25 @@ jobs: # Validate that the nuspec directory contains a Public/ Private directory "Private" | should -bein $moduleRootDirectories.name "Public" | should -bein $moduleRootDirectories.name + Validate-Module: + needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + .github + - uses: actions/cache@v4 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - env: + RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} + shell: pwsh + run: | + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation Setup-Org: needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] runs-on: ubuntu-latest @@ -183,7 +173,7 @@ jobs: - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependencies + key: PS-Dependancies - name: Setup Org Variables shell: pwsh env: @@ -220,7 +210,7 @@ jobs: - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependencies + key: PS-Dependancies - uses: actions/download-artifact@v4 with: name: jumpcloud-vars @@ -242,13 +232,10 @@ jobs: } } Set-Variable -Name PesterParams_ApiKey -Value "$env:PESTER_APIKEY" -Scope Global - # Import JC Module Import-Module "${{github.workspace}}/PowerShell/JumpCloud Module/JumpCloud.psd1" - # Authenticate to JC Org Connect-JCOnline -JumpCloudApiKey:("$env:PESTER_APIKEY") -force | Out-Null - # Invoke Pester . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery" Test-Module-MSP: @@ -264,7 +251,7 @@ jobs: - uses: actions/cache@v3 with: path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependencies + key: PS-Dependancies - shell: pwsh env: PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} @@ -273,5 +260,4 @@ jobs: PESTER_PROVIDER_ID: ${{ secrets.PESTER_PROVIDER_ID }} run: | Set-Variable -Name PesterParams_ApiKeyMsp -Value "$env:PESTER_MSP_APIKEY" -Scope Global - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ProviderID "$env:PESTER_PROVIDER_ID" -RequiredModulesRepo "PSGallery" -MSP From b113dc8fcc1aa5fffca1e4a7fa1fb88faa307c68 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:58:01 -0700 Subject: [PATCH 48/60] remove cache --- .github/workflows/powershell-module-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 0a675a09c..2089497d3 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -74,7 +74,6 @@ jobs: path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependencies - name: Install Dependencies - if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh env: PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} From 160cc49d53082be5643a3172b70d84ece7d1c33b Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 12:58:10 -0700 Subject: [PATCH 49/60] cache --- .github/workflows/powershell-module-ci.yml | 33 ---------------------- 1 file changed, 33 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 2089497d3..9dcd51144 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -107,39 +107,6 @@ jobs: } } } - Build-Nuspec-Nupkg: - needs: Setup-Build-Dependencies - runs-on: windows-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/cache@v4 - with: - path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependencies - - name: Build Nuspec - shell: pwsh - run: | - $ErrorActionPreference = 'Stop' - . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery - - name: Pack nuspec - shell: pwsh - run: | - nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - - name: Validate NuPkg File - shell: pwsh - run: | - $NupkgPathDirectory = (Get-ChildItem -Path:("./*.nupkg")).Directory - $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName - Write-Host "NuPkg Path: $nupkgPath" - mkdir $NupkgPathDirectory/nupkg_module - unzip $nupkgPath -d $NupkgPathDirectory/nupkg_module - $moduleRootFiles = Get-ChildItem -File -Path:("$NupkgPathDirectory/nupkg_module") - $moduleRootDirectories = Get-ChildItem -Directory -Path:("$NupkgPathDirectory/nupkg_module") - Write-Host "Module Files:\n$moduleRootFiles" - Write-Host "Module Directories:\n$moduleRootDirectories" - # Validate that the nuspec directory contains a Public/ Private directory - "Private" | should -bein $moduleRootDirectories.name - "Public" | should -bein $moduleRootDirectories.name Validate-Module: needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] runs-on: ubuntu-latest From b843f94e6f369f85c488dcf6b93385dd6fec7ba7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 13:17:02 -0700 Subject: [PATCH 50/60] nuspec --- .github/workflows/powershell-module-ci.yml | 262 ++++++++++++--------- 1 file changed, 151 insertions(+), 111 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 9dcd51144..562e00930 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -61,7 +61,7 @@ jobs: run: | # validate release type variables $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') - Setup-Build-Dependencies: + Setup-Build-Dependancies: needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] runs-on: windows-latest timeout-minutes: 10 @@ -72,15 +72,16 @@ jobs: uses: actions/cache@v4 with: path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' - key: PS-Dependencies - - name: Install Dependencies + key: PS-Dependancies + - name: Install dependencies + if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh env: PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} PESTER_ORGID: ${{ secrets.PESTER_ORGID }} PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted + Set-PSRepository PSGallery -InstallationPolicy Trusted If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force @@ -107,123 +108,162 @@ jobs: } } } - Validate-Module: - needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: ubuntu-latest - timeout-minutes: 10 + Build-Nuspec-Nupkg: + needs: Setup-Build-Dependancies + runs-on: windows-latest steps: - uses: actions/checkout@v4 - with: - sparse-checkout: | - PowerShell - .github - uses: actions/cache@v4 with: path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies - - env: - RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} + - name: Build Nuspec shell: pwsh run: | - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation - Setup-Org: - needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: ubuntu-latest - name: Setup Org Upload Variable Artifact - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - PowerShell - .github - - uses: actions/cache@v3 - with: - path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies - - name: Setup Org Variables + $ErrorActionPreference = 'Stop' + . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery + - name: Pack nuspec shell: pwsh - env: - PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} - PESTER_ORGID: ${{ secrets.PESTER_ORGID }} - PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - # Setup Org - # $variableArray = New-Object System.Collections.Generic.List[PSCustomObject] - # Load Get-Config.ps1 - . "./PowerShell/Deploy/Get-Config.ps1" - Write-Host ('[status] Setting up org') - $variables = . ("./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1") -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" - $variables | ConvertTo-Json -Depth 10 | Out-File -FilePath /home/runner/.local/share/powershell/Modules/PesterVariables.json - - uses: ./.github/actions/upload-secure-artifact - with: - name: jumpcloud-vars - path: /home/runner/.local/share/powershell/Modules/PesterVariables.json - Test-Module: - needs: ["Setup-Build-Dependencies", "Check-PR-Labels", "Setup-Org"] - runs-on: ubuntu-latest - timeout-minutes: 75 - strategy: - fail-fast: false - matrix: - job_group: [0, 1, 2] - name: Run Pester Tests and Upload Results - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - PowerShell - .github - - uses: actions/cache@v3 - with: - path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies - - uses: actions/download-artifact@v4 - with: - name: jumpcloud-vars - - name: Test PWSH Module + nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 + - name: Validate NuPkg File shell: pwsh - env: - PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} - PESTER_ORGID: ${{ secrets.PESTER_ORGID }} - PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - # Setup Variables for Pester Run - $env:job_group = ${{ matrix.job_group }} - $PesterParams = Get-Content -Raw ${{ github.workspace }}/PesterVariables.json | ConvertFrom-JSON - write-host "[status] Importing $($PesterParams.count) variables from SetupOrg" - $PesterParams | Foreach-Object { - if ($_.Name){ - Write-Host ("[status] Setting variable $($_.Name) with value $($_.Value)") - Set-Variable -Name $_.Name -Value $_.Value -Scope Global - } - } - Set-Variable -Name PesterParams_ApiKey -Value "$env:PESTER_APIKEY" -Scope Global - # Import JC Module - Import-Module "${{github.workspace}}/PowerShell/JumpCloud Module/JumpCloud.psd1" - # Authenticate to JC Org - Connect-JCOnline -JumpCloudApiKey:("$env:PESTER_APIKEY") -force | Out-Null - # Invoke Pester - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery" - Test-Module-MSP: - needs: ["Setup-Build-Dependencies", "Check-PR-Labels"] - runs-on: ubuntu-latest - timeout-minutes: 20 - steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - PowerShell - .github - - uses: actions/cache@v3 + $NupkgPathDirectory = (Get-ChildItem -Path:("./*.nupkg")).Directory + $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName + Write-Host "NuPkg Path: $nupkgPath" + mkdir $NupkgPathDirectory/nupkg_module + unzip $nupkgPath -d $NupkgPathDirectory/nupkg_module + $moduleRootFiles = Get-ChildItem -File -Path:("$NupkgPathDirectory/nupkg_module") + $moduleRootDirectories = Get-ChildItem -Directory -Path:("$NupkgPathDirectory/nupkg_module") + Write-Host "Module Files:\n$moduleRootFiles" + Write-Host "Module Directories:\n$moduleRootDirectories" + # Validate that the nuspec directory contains a Public/ Private directory + "Private" | should -bein $moduleRootDirectories.name + "Public" | should -bein $moduleRootDirectories.name + - name: Upload Nupkg + uses: ./.github/actions/upload-secure-artifact with: - path: "/home/runner/.local/share/powershell/Modules/" - key: PS-Dependancies - - shell: pwsh - env: - PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} - PESTER_ORGID: ${{ secrets.PESTER_ORGID }} - PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} - PESTER_PROVIDER_ID: ${{ secrets.PESTER_PROVIDER_ID }} - run: | - Set-Variable -Name PesterParams_ApiKeyMsp -Value "$env:PESTER_MSP_APIKEY" -Scope Global - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ProviderID "$env:PESTER_PROVIDER_ID" -RequiredModulesRepo "PSGallery" -MSP + name: jumpcloud-module-nupkg + path: /home/runner/work/support/support/JumpCloud.*.nupkg + retention-days: 1 + # Validate-Module: + # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + # runs-on: ubuntu-latest + # timeout-minutes: 10 + # steps: + # - uses: actions/checkout@v4 + # with: + # sparse-checkout: | + # PowerShell + # .github + # - uses: actions/cache@v3 + # with: + # path: "/home/runner/.local/share/powershell/Modules/" + # key: PS-Dependancies + # - env: + # RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} + # shell: pwsh + # run: | + # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + # Setup-Org: + # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + # runs-on: ubuntu-latest + # name: Setup Org Upload Variable Artifact + # steps: + # - uses: actions/checkout@v4 + # with: + # sparse-checkout: | + # PowerShell + # .github + # - uses: actions/cache@v3 + # with: + # path: "/home/runner/.local/share/powershell/Modules/" + # key: PS-Dependancies + # - name: Setup Org Variables + # shell: pwsh + # env: + # PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + # PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + # PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} + # run: | + # # Setup Org + # # $variableArray = New-Object System.Collections.Generic.List[PSCustomObject] + # # Load Get-Config.ps1 + # . "./PowerShell/Deploy/Get-Config.ps1" + # Write-Host ('[status] Setting up org') + # $variables = . ("./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1") -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" + # $variables | ConvertTo-Json -Depth 10 | Out-File -FilePath /home/runner/.local/share/powershell/Modules/PesterVariables.json + # - uses: ./.github/actions/upload-secure-artifact + # with: + # name: jumpcloud-vars + # path: /home/runner/.local/share/powershell/Modules/PesterVariables.json + # Test-Module: + # needs: ["Setup-Build-Dependancies", "Check-PR-Labels", "Setup-Org"] + # runs-on: ubuntu-latest + # timeout-minutes: 75 + # strategy: + # fail-fast: false + # matrix: + # job_group: [0, 1, 2] + # name: Run Pester Tests and Upload Results + # steps: + # - uses: actions/checkout@v4 + # with: + # sparse-checkout: | + # PowerShell + # .github + # - uses: actions/cache@v3 + # with: + # path: "/home/runner/.local/share/powershell/Modules/" + # key: PS-Dependancies + # - uses: actions/download-artifact@v4 + # with: + # name: jumpcloud-vars + # - name: Test PWSH Module + # shell: pwsh + # env: + # PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + # PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + # PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} + # run: | + # # Setup Variables for Pester Run + # $env:job_group = ${{ matrix.job_group }} + # $PesterParams = Get-Content -Raw ${{ github.workspace }}/PesterVariables.json | ConvertFrom-JSON + # write-host "[status] Importing $($PesterParams.count) variables from SetupOrg" + # $PesterParams | Foreach-Object { + # if ($_.Name){ + # Write-Host ("[status] Setting variable $($_.Name) with value $($_.Value)") + # Set-Variable -Name $_.Name -Value $_.Value -Scope Global + # } + # } + # Set-Variable -Name PesterParams_ApiKey -Value "$env:PESTER_APIKEY" -Scope Global + # # Import JC Module + # Import-Module "${{github.workspace}}/PowerShell/JumpCloud Module/JumpCloud.psd1" + # # Authenticate to JC Org + # Connect-JCOnline -JumpCloudApiKey:("$env:PESTER_APIKEY") -force | Out-Null + # # Invoke Pester + # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery" + # Test-Module-MSP: + # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + # runs-on: ubuntu-latest + # timeout-minutes: 20 + # steps: + # - uses: actions/checkout@v4 + # with: + # sparse-checkout: | + # PowerShell + # .github + # - uses: actions/cache@v3 + # with: + # path: "/home/runner/.local/share/powershell/Modules/" + # key: PS-Dependancies + # - shell: pwsh + # env: + # PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + # PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + # PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} + # PESTER_PROVIDER_ID: ${{ secrets.PESTER_PROVIDER_ID }} + # run: | + # Set-Variable -Name PesterParams_ApiKeyMsp -Value "$env:PESTER_MSP_APIKEY" -Scope Global + # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ProviderID "$env:PESTER_PROVIDER_ID" -RequiredModulesRepo "PSGallery" -MSP From 958a55008542da45745d9e550ea81de06ed3c300 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 13:23:39 -0700 Subject: [PATCH 51/60] path --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 562e00930..42cc57f0a 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -115,7 +115,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/cache@v4 with: - path: "/home/runner/.local/share/powershell/Modules/" + path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependancies - name: Build Nuspec shell: pwsh From 1256c6c4fd8c490e24e2b314481558226c7a84b8 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 13:28:37 -0700 Subject: [PATCH 52/60] validation module --- .github/workflows/powershell-module-ci.yml | 38 +++++++++++----------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 42cc57f0a..511b1612b 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -147,25 +147,25 @@ jobs: name: jumpcloud-module-nupkg path: /home/runner/work/support/support/JumpCloud.*.nupkg retention-days: 1 - # Validate-Module: - # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] - # runs-on: ubuntu-latest - # timeout-minutes: 10 - # steps: - # - uses: actions/checkout@v4 - # with: - # sparse-checkout: | - # PowerShell - # .github - # - uses: actions/cache@v3 - # with: - # path: "/home/runner/.local/share/powershell/Modules/" - # key: PS-Dependancies - # - env: - # RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} - # shell: pwsh - # run: | - # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + Validate-Module: + needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + runs-on: ubuntu-latest + timeout-minutes: 10 + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + .github + - uses: actions/cache@v4 + with: + path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' + key: PS-Dependancies + - env: + RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} + shell: pwsh + run: | + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation # Setup-Org: # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] # runs-on: ubuntu-latest From 9b45adcf8564e0493299fdeca9d8b8fe8cd1e45d Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 13:43:02 -0700 Subject: [PATCH 53/60] test deploy path --- .github/workflows/powershell-module-ci.yml | 51 +++++++++++++++------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 511b1612b..fc2cf686f 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -108,6 +108,7 @@ jobs: } } } + Build-Nuspec-Nupkg: needs: Setup-Build-Dependancies runs-on: windows-latest @@ -147,25 +148,45 @@ jobs: name: jumpcloud-module-nupkg path: /home/runner/work/support/support/JumpCloud.*.nupkg retention-days: 1 - Validate-Module: - needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] - runs-on: ubuntu-latest - timeout-minutes: 10 + Deploy-Nupkg: + needs: [Build-Nuspec-Nupkg] + runs-on: windows-latest steps: - - uses: actions/checkout@v4 - with: - sparse-checkout: | - PowerShell - .github - - uses: actions/cache@v4 + - name: Download nupkg artifact + uses: actions/download-artifact@v4 with: - path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' - key: PS-Dependancies - - env: - RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} + name: jumpcloud-module-nupkg + - name: Publish shell: pwsh run: | - . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + # add nuget source for PSGallery: + # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery + # get nupkg artifact: + $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName + # test + $nupkgPath | Should -Exist + Write-Host "Nupkg Artifact Restored: $nupkgPath" + # nuget push from here: + # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey + # Validate-Module: + # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + # runs-on: ubuntu-latest + # timeout-minutes: 10 + # steps: + # - uses: actions/checkout@v4 + # with: + # sparse-checkout: | + # PowerShell + # .github + # - uses: actions/cache@v4 + # with: + # path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' + # key: PS-Dependancies + # - env: + # RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} + # shell: pwsh + # run: | + # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation # Setup-Org: # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] # runs-on: ubuntu-latest From 5485bfc19a4173c8038fa38dc7bba908975698a7 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 13:48:25 -0700 Subject: [PATCH 54/60] nuspec --- .github/workflows/powershell-module-ci.yml | 2 +- .github/workflows/release-workflow.yml | 48 ++++++++-------------- 2 files changed, 19 insertions(+), 31 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index fc2cf686f..0f0cc632b 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -146,7 +146,7 @@ jobs: uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg - path: /home/runner/work/support/support/JumpCloud.*.nupkg + path: ${{ github.workspace }}/JumpCloud.*.nupkg retention-days: 1 Deploy-Nupkg: needs: [Build-Nuspec-Nupkg] diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index ac2a6909a..f6283874a 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -44,42 +44,25 @@ jobs: Setup-Build-Dependancies: needs: ["Filter-Branch", "Check-PR-Labels"] - runs-on: ubuntu-latest + runs-on: windows-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Setup PowerShell Module Cache id: cacher - uses: actions/cache@v3 + uses: actions/cache@v4 with: - path: "/home/runner/.local/share/powershell/Modules/" + path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependancies - - uses: nuget/setup-nuget@v2 - - name: Install System Dependencies - if: steps.cacher.outputs.cache-hit != 'true' - run: | - sudo apt install ca-certificates gnupg - sudo gpg --homedir /tmp --no-default-keyring --keyring /usr/share/keyrings/mono-official-archive-keyring.gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF - echo "deb [signed-by=/usr/share/keyrings/mono-official-archive-keyring.gpg] https://download.mono-project.com/repo/ubuntu stable-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list - sudo apt update - sudo apt install mono-devel - - if ! command -v nuget >/dev/null 2>&1; then - echo "Error: NuGet is not installed." - exit 1 - fi - echo "NuGet is installed. Continuing with the tests..." - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' shell: pwsh run: | Set-PSRepository PSGallery -InstallationPolicy Trusted - If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force } - $PSDependencies = @{ 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } @@ -87,26 +70,30 @@ jobs: 'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } 'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } 'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } - 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.35'} - 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.39'} - 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.23'} + 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} + 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} + 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} + 'powershell-yaml' = @{Repository = 'PSGallery'; RequiredVersion = '0.4.7'} } - foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force + if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force + } else { + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -AllowClobber + } } } Build-Nuspec-Nupkg: needs: Setup-Build-Dependancies - runs-on: ubuntu-latest + runs-on: windows-latest steps: - uses: actions/checkout@v4 - - uses: actions/cache@v3 + - uses: actions/cache@v4 with: - path: "/home/runner/.local/share/powershell/Modules/" + path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' key: PS-Dependancies - name: Build Nuspec shell: pwsh @@ -136,7 +123,8 @@ jobs: uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg - path: /home/runner/work/support/support/JumpCloud.*.nupkg + path: | + ${{ github.workspace }}/JumpCloud.*.nupkg retention-days: 1 Manual-Approval-Release: @@ -166,7 +154,7 @@ jobs: Deploy-Nupkg: needs: [Manual-Approval-Release, Build-Nuspec-Nupkg] - runs-on: ubuntu-latest + runs-on: windows-latest steps: - name: Download nupkg artifact uses: actions/download-artifact@v4 From 975d7385147fa4a29069e5adbcf42cc553b0fadb Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 14:07:16 -0700 Subject: [PATCH 55/60] nupkg path --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 0f0cc632b..354b1dd14 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -146,7 +146,7 @@ jobs: uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg - path: ${{ github.workspace }}/JumpCloud.*.nupkg + path: ${{ github.workspace }}/support/JumpCloud.*.nupkg retention-days: 1 Deploy-Nupkg: needs: [Build-Nuspec-Nupkg] From fa4c7367bac73d299a1f3bbfd309cc240e086b5f Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 14:15:51 -0700 Subject: [PATCH 56/60] path --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 354b1dd14..5b23ac372 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -146,7 +146,7 @@ jobs: uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg - path: ${{ github.workspace }}/support/JumpCloud.*.nupkg + path: 'D:\a\support\support\JumpCloud.*.nupkg' retention-days: 1 Deploy-Nupkg: needs: [Build-Nuspec-Nupkg] From 6cf54764c876097fb77f593a687fdcec505cf3a2 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 14:25:56 -0700 Subject: [PATCH 57/60] pack --- .github/workflows/powershell-module-ci.yml | 42 +++++++++++----------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 5b23ac372..8cfede5ef 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -146,28 +146,28 @@ jobs: uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg - path: 'D:\a\support\support\JumpCloud.*.nupkg' + path: D:\a\support\support\JumpCloud.*.nupkg retention-days: 1 - Deploy-Nupkg: - needs: [Build-Nuspec-Nupkg] - runs-on: windows-latest - steps: - - name: Download nupkg artifact - uses: actions/download-artifact@v4 - with: - name: jumpcloud-module-nupkg - - name: Publish - shell: pwsh - run: | - # add nuget source for PSGallery: - # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery - # get nupkg artifact: - $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName - # test - $nupkgPath | Should -Exist - Write-Host "Nupkg Artifact Restored: $nupkgPath" - # nuget push from here: - # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey + # Deploy-Nupkg: + # needs: [Build-Nuspec-Nupkg] + # runs-on: windows-latest + # steps: + # - name: Download nupkg artifact + # uses: actions/download-artifact@v4 + # with: + # name: jumpcloud-module-nupkg + # - name: Publish + # shell: pwsh + # run: | + # # add nuget source for PSGallery: + # # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery + # # get nupkg artifact: + # $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName + # # test + # $nupkgPath | Should -Exist + # Write-Host "Nupkg Artifact Restored: $nupkgPath" + # # nuget push from here: + # # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey # Validate-Module: # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] # runs-on: ubuntu-latest From 9d2edaab47c40c95ca1051cf690924fdea324d86 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 14:32:57 -0700 Subject: [PATCH 58/60] path --- .github/workflows/powershell-module-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 8cfede5ef..5b1da36f2 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -146,7 +146,7 @@ jobs: uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg - path: D:\a\support\support\JumpCloud.*.nupkg + path: D:/a/support/support/JumpCloud.*.nupkg retention-days: 1 # Deploy-Nupkg: # needs: [Build-Nuspec-Nupkg] From 04fd3b4d91895e32ce11516fd2cd41b746bad34d Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Thu, 17 Apr 2025 14:46:31 -0700 Subject: [PATCH 59/60] validate artifact pack --- .github/workflows/powershell-module-ci.yml | 40 +++++++++---------- .../Docs/Set-JCSettingsFile.md | 4 +- .../Policies/New-UriListItem.Tests.ps1 | 0 .../JumpCloud Module/en-Us/JumpCloud-help.xml | 18 ++++++++- 4 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 PowerShell/JumpCloud Module/Tests/Private/Policies/New-UriListItem.Tests.ps1 diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 5b1da36f2..6bdc5dd13 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -148,26 +148,26 @@ jobs: name: jumpcloud-module-nupkg path: D:/a/support/support/JumpCloud.*.nupkg retention-days: 1 - # Deploy-Nupkg: - # needs: [Build-Nuspec-Nupkg] - # runs-on: windows-latest - # steps: - # - name: Download nupkg artifact - # uses: actions/download-artifact@v4 - # with: - # name: jumpcloud-module-nupkg - # - name: Publish - # shell: pwsh - # run: | - # # add nuget source for PSGallery: - # # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery - # # get nupkg artifact: - # $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName - # # test - # $nupkgPath | Should -Exist - # Write-Host "Nupkg Artifact Restored: $nupkgPath" - # # nuget push from here: - # # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey + Deploy-Nupkg: + needs: [Build-Nuspec-Nupkg] + runs-on: windows-latest + steps: + - name: Download nupkg artifact + uses: actions/download-artifact@v4 + with: + name: jumpcloud-module-nupkg + - name: Publish + shell: pwsh + run: | + # add nuget source for PSGallery: + # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery + # get nupkg artifact: + $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName + # test + $nupkgPath | Should -Exist + Write-Host "Nupkg Artifact Restored: $nupkgPath" + # nuget push from here: + # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey # Validate-Module: # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] # runs-on: ubuntu-latest diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md index 7f6b8fb85..1bb2c174f 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCSettingsFile.md @@ -14,8 +14,8 @@ Updates the JumpCloud Module Settings File ## SYNTAX ``` -Set-JCSettingsFile [-moduleBannerMessageCount ] - [-parallelOverride ] [] +Set-JCSettingsFile [-parallelOverride ] + [-moduleBannerMessageCount ] [] ``` ## DESCRIPTION diff --git a/PowerShell/JumpCloud Module/Tests/Private/Policies/New-UriListItem.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Private/Policies/New-UriListItem.Tests.ps1 new file mode 100644 index 000000000..e69de29bb diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 42c184eaf..4289bbb63 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -11002,7 +11002,7 @@ Get-JCUser -Username cClemons Get-JCUserGroupMember - + ByID If searching for a User Group using the GroupID populate the GroupID in the -ByID field. @@ -11034,7 +11034,7 @@ Get-JCUser -Username cClemons - + ByID If searching for a User Group using the GroupID populate the GroupID in the -ByID field. @@ -12738,6 +12738,13 @@ PS C:\> New-JCPolicy -TemplateName darwin_Login_Window_Text -Values $policyV This command would create a new Windows Custom Registry Policy named "Windows - Imported Custom Registry Settings" and populate the values from a registry file. .Reg registry files can be passed into New-JCPolicy as long as the TemplateName is specified with the corresponding "windows_Advanced:_Custom_Registry_Keys" template. .Reg files will be converted and uploaded to the JumpCloud policy as long as they contain "DWORD", "EXPAND_SZ", "MULTI_SZ", "SZ" or "QWORD" type data. + + -------------------------- Example 6 -------------------------- + PS C:\> New-JCPolicy -TemplateName custom_oma_uri_mdm_windows -Name "Windows - Custom OMA MDM Policy" -uriList '(@( @{format = "string"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage; value = "pathToImage" }, @{format = "int"; uri = "./Device/Vendor/MSFT/Policy/Config/DeviceLock/AccountLockoutPolicy"; value = "1" } ))' + + This command creates a JumpCloud policy named "Windows - Custom OMA MDM Policy" using the custom_oma_uri_mdm_windows template. It defines two OMA-URI configurations: a string value for EnforceLockScreenAndLogonImage and an integer value for AccountLockoutPolicy. + + @@ -19316,6 +19323,13 @@ PS C:\> Set-JCPolicy -PolicyName "macOS - Login Window Policy" -Values $poli This command would overwrite the registry policy's existing values with the imported set of .Reg keys specified by the "RegistryFile" parameter. .Reg files will be converted and uploaded to the JumpCloud policy as long as they contain "DWORD", "EXPAND_SZ", "MULTI_SZ", "SZ" or "QWORD" type data. + + -------------------------- Example 7 -------------------------- + PS C:\> Set-JCPolicy -PolicyName "Windows - Custom OMA MDM Policy" -uriList '(@( @{format = "string"; uri = "./Vendor/MSFT/Policy/Config/DeviceLock/EnforceLockScreenAndLogonImage; value = "pathToImage" }, @{format = "int"; uri = "./Device/Vendor/MSFT/Policy/Config/DeviceLock/AccountLockoutPolicy"; value = "2" } ))' + + This command modifies the existing JumpCloud policy named "Windows - Custom OMA MDM Policy". It updates the policy's OMA-URI settings using the -uriList parameter. The EnforceLockScreenAndLogonImage setting, a string, remains set to "pathToImage". The AccountLockoutPolicy setting, an integer, is updated from its previous value to "2", effectively changing the account lockout policy configuration. + + From 21d09fd918103f879c18c1c231fc1909b51b04e2 Mon Sep 17 00:00:00 2001 From: Ken Maranion Date: Fri, 18 Apr 2025 07:35:15 -0700 Subject: [PATCH 60/60] workflows update --- .github/workflows/powershell-module-ci.yml | 289 +++++++++------------ .github/workflows/release-workflow.yml | 10 +- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleChangelog.md | 2 +- 4 files changed, 125 insertions(+), 178 deletions(-) diff --git a/.github/workflows/powershell-module-ci.yml b/.github/workflows/powershell-module-ci.yml index 6bdc5dd13..d0984ae9a 100644 --- a/.github/workflows/powershell-module-ci.yml +++ b/.github/workflows/powershell-module-ci.yml @@ -43,6 +43,7 @@ jobs: $RELEASE_TYPE = $item } } + if ($typeCount -eq 1) { echo "RELEASE_TYPE=$RELEASE_TYPE" >> $env:GITHUB_OUTPUT } else { @@ -63,15 +64,15 @@ jobs: $env:RELEASE_TYPE | Should -BeIn @('major','minor','patch','manual') Setup-Build-Dependancies: needs: ["Filter-Branch", "Check-PR-Labels", "Validate-Env-Variables"] - runs-on: windows-latest + runs-on: ubuntu-latest timeout-minutes: 10 steps: - uses: actions/checkout@v4 - name: Setup PowerShell Module Cache id: cacher - uses: actions/cache@v4 + uses: actions/cache@v3 with: - path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' + path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies - name: Install dependencies if: steps.cacher.outputs.cache-hit != 'true' @@ -82,10 +83,12 @@ jobs: PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | Set-PSRepository PSGallery -InstallationPolicy Trusted + If (!(Get-PackageProvider -Name:('NuGet') -ListAvailable -ErrorAction:('SilentlyContinue'))) { Write-Host ('[status]Installing package provider NuGet'); Install-PackageProvider -Name:('NuGet') -Scope:('CurrentUser') -Force } + $PSDependencies = @{ 'PowerShellGet' = @{Repository = 'PSGallery'; RequiredVersion = '3.0.12-beta' } 'PackageManagement' = @{Repository = 'PSGallery'; RequiredVersion = '1.4.8.1' } @@ -98,193 +101,139 @@ jobs: 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} 'powershell-yaml' = @{Repository = 'PSGallery'; RequiredVersion = '0.4.7'} } + foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { Write-Host("[status]Installing module: '$RequiredModule'; version: $($PSDependencies[$RequiredModule].RequiredVersion) from $($PSDependencies[$RequiredModule].Repository)") if ($($PSDependencies[$RequiredModule].RequiredVersion) -eq "latest"){ Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -AllowPrerelease -Force } else { - Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force -AllowClobber + Install-Module -Name $RequiredModule -Repository:($($PSDependencies[$RequiredModule].Repository)) -RequiredVersion:($($PSDependencies[$RequiredModule].RequiredVersion)) -AllowPrerelease -Force } } } - Build-Nuspec-Nupkg: - needs: Setup-Build-Dependancies - runs-on: windows-latest + Validate-Module: + needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + runs-on: ubuntu-latest + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - uses: actions/cache@v4 with: - path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' + sparse-checkout: | + PowerShell + .github + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" key: PS-Dependancies - - name: Build Nuspec - shell: pwsh - run: | - $ErrorActionPreference = 'Stop' - . "${{ github.workspace }}/PowerShell/Deploy/BuildNuspecFromPsd1.ps1" -RequiredModulesRepo PSGallery - - name: Pack nuspec + - env: + RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} shell: pwsh run: | - nuget pack "${{ github.workspace }}/PowerShell/JumpCloud Module/JumpCloud.nuspec" -Properties NoWarn=NU5111,NU5110 - - name: Validate NuPkg File + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation + Setup-Org: + needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + runs-on: ubuntu-latest + name: Setup Org Upload Variable Artifact + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + .github + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - name: Setup Org Variables shell: pwsh + env: + PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - $NupkgPathDirectory = (Get-ChildItem -Path:("./*.nupkg")).Directory - $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName - Write-Host "NuPkg Path: $nupkgPath" - mkdir $NupkgPathDirectory/nupkg_module - unzip $nupkgPath -d $NupkgPathDirectory/nupkg_module - $moduleRootFiles = Get-ChildItem -File -Path:("$NupkgPathDirectory/nupkg_module") - $moduleRootDirectories = Get-ChildItem -Directory -Path:("$NupkgPathDirectory/nupkg_module") - Write-Host "Module Files:\n$moduleRootFiles" - Write-Host "Module Directories:\n$moduleRootDirectories" - # Validate that the nuspec directory contains a Public/ Private directory - "Private" | should -bein $moduleRootDirectories.name - "Public" | should -bein $moduleRootDirectories.name - - name: Upload Nupkg - uses: ./.github/actions/upload-secure-artifact + # Setup Org + # $variableArray = New-Object System.Collections.Generic.List[PSCustomObject] + # Load Get-Config.ps1 + . "./PowerShell/Deploy/Get-Config.ps1" + Write-Host ('[status] Setting up org') + $variables = . ("./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1") -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" + $variables | ConvertTo-Json -Depth 10 | Out-File -FilePath /home/runner/.local/share/powershell/Modules/PesterVariables.json + - uses: ./.github/actions/upload-secure-artifact with: - name: jumpcloud-module-nupkg - path: D:/a/support/support/JumpCloud.*.nupkg - retention-days: 1 - Deploy-Nupkg: - needs: [Build-Nuspec-Nupkg] - runs-on: windows-latest + name: jumpcloud-vars + path: /home/runner/.local/share/powershell/Modules/PesterVariables.json + Test-Module: + needs: ["Setup-Build-Dependancies", "Check-PR-Labels", "Setup-Org"] + runs-on: ubuntu-latest + timeout-minutes: 75 + strategy: + fail-fast: false + matrix: + job_group: [0, 1, 2] + name: Run Pester Tests and Upload Results steps: - - name: Download nupkg artifact - uses: actions/download-artifact@v4 + - uses: actions/checkout@v4 with: - name: jumpcloud-module-nupkg - - name: Publish + sparse-checkout: | + PowerShell + .github + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - uses: actions/download-artifact@v4 + with: + name: jumpcloud-vars + - name: Test PWSH Module shell: pwsh + env: + PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} run: | - # add nuget source for PSGallery: - # dotnet nuget add source "https://www.powershellgallery.com/api/v2/package" --name PSGallery - # get nupkg artifact: - $nupkgPath = (Get-ChildItem -Path:("./*.nupkg")).FullName - # test - $nupkgPath | Should -Exist - Write-Host "Nupkg Artifact Restored: $nupkgPath" - # nuget push from here: - # dotnet nuget push $nupkgPath --source PSGallery --api-key $env:NuGetApiKey - # Validate-Module: - # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] - # runs-on: ubuntu-latest - # timeout-minutes: 10 - # steps: - # - uses: actions/checkout@v4 - # with: - # sparse-checkout: | - # PowerShell - # .github - # - uses: actions/cache@v4 - # with: - # path: 'C:\Users\runneradmin\Documents\PowerShell\Modules\' - # key: PS-Dependancies - # - env: - # RELEASE_TYPE: ${{ needs.Check-PR-Labels.outputs.RELEASE_TYPE }} - # shell: pwsh - # run: | - # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -ModuleValidation - # Setup-Org: - # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] - # runs-on: ubuntu-latest - # name: Setup Org Upload Variable Artifact - # steps: - # - uses: actions/checkout@v4 - # with: - # sparse-checkout: | - # PowerShell - # .github - # - uses: actions/cache@v3 - # with: - # path: "/home/runner/.local/share/powershell/Modules/" - # key: PS-Dependancies - # - name: Setup Org Variables - # shell: pwsh - # env: - # PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} - # PESTER_ORGID: ${{ secrets.PESTER_ORGID }} - # PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} - # run: | - # # Setup Org - # # $variableArray = New-Object System.Collections.Generic.List[PSCustomObject] - # # Load Get-Config.ps1 - # . "./PowerShell/Deploy/Get-Config.ps1" - # Write-Host ('[status] Setting up org') - # $variables = . ("./PowerShell/JumpCloud Module/Tests/SetupOrg.ps1") -JumpCloudApiKey "$env:PESTER_APIKEY" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" - # $variables | ConvertTo-Json -Depth 10 | Out-File -FilePath /home/runner/.local/share/powershell/Modules/PesterVariables.json - # - uses: ./.github/actions/upload-secure-artifact - # with: - # name: jumpcloud-vars - # path: /home/runner/.local/share/powershell/Modules/PesterVariables.json - # Test-Module: - # needs: ["Setup-Build-Dependancies", "Check-PR-Labels", "Setup-Org"] - # runs-on: ubuntu-latest - # timeout-minutes: 75 - # strategy: - # fail-fast: false - # matrix: - # job_group: [0, 1, 2] - # name: Run Pester Tests and Upload Results - # steps: - # - uses: actions/checkout@v4 - # with: - # sparse-checkout: | - # PowerShell - # .github - # - uses: actions/cache@v3 - # with: - # path: "/home/runner/.local/share/powershell/Modules/" - # key: PS-Dependancies - # - uses: actions/download-artifact@v4 - # with: - # name: jumpcloud-vars - # - name: Test PWSH Module - # shell: pwsh - # env: - # PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} - # PESTER_ORGID: ${{ secrets.PESTER_ORGID }} - # PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} - # run: | - # # Setup Variables for Pester Run - # $env:job_group = ${{ matrix.job_group }} - # $PesterParams = Get-Content -Raw ${{ github.workspace }}/PesterVariables.json | ConvertFrom-JSON - # write-host "[status] Importing $($PesterParams.count) variables from SetupOrg" - # $PesterParams | Foreach-Object { - # if ($_.Name){ - # Write-Host ("[status] Setting variable $($_.Name) with value $($_.Value)") - # Set-Variable -Name $_.Name -Value $_.Value -Scope Global - # } - # } - # Set-Variable -Name PesterParams_ApiKey -Value "$env:PESTER_APIKEY" -Scope Global - # # Import JC Module - # Import-Module "${{github.workspace}}/PowerShell/JumpCloud Module/JumpCloud.psd1" - # # Authenticate to JC Org - # Connect-JCOnline -JumpCloudApiKey:("$env:PESTER_APIKEY") -force | Out-Null - # # Invoke Pester - # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery" - # Test-Module-MSP: - # needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] - # runs-on: ubuntu-latest - # timeout-minutes: 20 - # steps: - # - uses: actions/checkout@v4 - # with: - # sparse-checkout: | - # PowerShell - # .github - # - uses: actions/cache@v3 - # with: - # path: "/home/runner/.local/share/powershell/Modules/" - # key: PS-Dependancies - # - shell: pwsh - # env: - # PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} - # PESTER_ORGID: ${{ secrets.PESTER_ORGID }} - # PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} - # PESTER_PROVIDER_ID: ${{ secrets.PESTER_PROVIDER_ID }} - # run: | - # Set-Variable -Name PesterParams_ApiKeyMsp -Value "$env:PESTER_MSP_APIKEY" -Scope Global - # . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ProviderID "$env:PESTER_PROVIDER_ID" -RequiredModulesRepo "PSGallery" -MSP + # Setup Variables for Pester Run + $env:job_group = ${{ matrix.job_group }} + $PesterParams = Get-Content -Raw ${{ github.workspace }}/PesterVariables.json | ConvertFrom-JSON + write-host "[status] Importing $($PesterParams.count) variables from SetupOrg" + $PesterParams | Foreach-Object { + if ($_.Name){ + Write-Host ("[status] Setting variable $($_.Name) with value $($_.Value)") + Set-Variable -Name $_.Name -Value $_.Value -Scope Global + } + } + Set-Variable -Name PesterParams_ApiKey -Value "$env:PESTER_APIKEY" -Scope Global + + # Import JC Module + Import-Module "${{github.workspace}}/PowerShell/JumpCloud Module/JumpCloud.psd1" + + # Authenticate to JC Org + Connect-JCOnline -JumpCloudApiKey:("$env:PESTER_APIKEY") -force | Out-Null + + # Invoke Pester + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKey "$env:PESTER_APIKEY" -ExcludeTagList "ModuleValidation", "JCDeployment", "MSP", "JCModule" -IncludeTagList "*" -RequiredModulesRepo "PSGallery" + Test-Module-MSP: + needs: ["Setup-Build-Dependancies", "Check-PR-Labels"] + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - uses: actions/checkout@v4 + with: + sparse-checkout: | + PowerShell + .github + - uses: actions/cache@v3 + with: + path: "/home/runner/.local/share/powershell/Modules/" + key: PS-Dependancies + - shell: pwsh + env: + PESTER_APIKEY: ${{ secrets.PESTER_APIKEY }} + PESTER_ORGID: ${{ secrets.PESTER_ORGID }} + PESTER_MSP_APIKEY: ${{ secrets.PESTER_MSP_APIKEY }} + PESTER_PROVIDER_ID: ${{ secrets.PESTER_PROVIDER_ID }} + run: | + Set-Variable -Name PesterParams_ApiKeyMsp -Value "$env:PESTER_MSP_APIKEY" -Scope Global + + . "./PowerShell/JumpCloud Module/Tests/InvokePester.ps1" -JumpCloudApiKeyMsp "$env:PESTER_MSP_APIKEY" -JumpCloudMspOrg "$env:PESTER_ORGID" -ProviderID "$env:PESTER_PROVIDER_ID" -RequiredModulesRepo "PSGallery" -MSP diff --git a/.github/workflows/release-workflow.yml b/.github/workflows/release-workflow.yml index f6283874a..d95e267a8 100644 --- a/.github/workflows/release-workflow.yml +++ b/.github/workflows/release-workflow.yml @@ -70,10 +70,9 @@ jobs: 'PlatyPS' = @{Repository = 'PSGallery'; RequiredVersion = '0.14.2' } 'AWS.Tools.Common' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } 'AWS.Tools.CodeArtifact' = @{Repository = 'PSGallery'; RequiredVersion = '4.1.122' } - 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} - 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} - 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = 'latest'} - 'powershell-yaml' = @{Repository = 'PSGallery'; RequiredVersion = '0.4.7'} + 'JumpCloud.SDK.V1' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.35'} + 'JumpCloud.SDK.V2' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.39'} + 'JumpCloud.SDK.DirectoryInsights' = @{Repository = 'PSGallery'; RequiredVersion = '0.0.23'} } foreach ($RequiredModule in $PSDependencies.Keys) { If ([System.String]::IsNullOrEmpty((Get-InstalledModule | Where-Object { $_.Name -eq $RequiredModule }))) { @@ -123,8 +122,7 @@ jobs: uses: ./.github/actions/upload-secure-artifact with: name: jumpcloud-module-nupkg - path: | - ${{ github.workspace }}/JumpCloud.*.nupkg + path: D:/a/support/support/JumpCloud.*.nupkg retention-days: 1 Manual-Approval-Release: diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index d5d03f0c9..bc95ae5c1 100644 --- 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/17/2025 +# Generated on: 4/18/2025 # @{ diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index b0683c286..549c51843 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,6 +1,6 @@ ## 2.18.0 -Release Date: April 17, 2025 +Release Date: April 18, 2025 #### RELEASE NOTES