diff --git a/1 b/1 deleted file mode 100644 index d00491fd7..000000000 --- a/1 +++ /dev/null @@ -1 +0,0 @@ -1 diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 8e8f580d5..f8e666dcb 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.14.2 +Help Version: 2.14.3 Locale: en-Us --- diff --git a/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md b/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md index ada3cf93a..47fe825c7 100644 --- a/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md +++ b/PowerShell/JumpCloud Module/Docs/New-JCPolicy.md @@ -19,13 +19,13 @@ At a minimum to display the dynamic set of parameters per template, the `Templat ### ByID (Default) ``` -New-JCPolicy -TemplateID [-Name ] [-Values ] +New-JCPolicy -TemplateID [-Name ] [-Values ] [-Notes ] [] ``` ### ByName ``` -New-JCPolicy -TemplateName [-Name ] [-Values ] +New-JCPolicy -TemplateName [-Name ] [-Values ] [-Notes ] [] ``` @@ -100,6 +100,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Notes +The notes of the policy to create. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -TemplateID The ID of the policy template to create as a new JumpCloud Policy diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md b/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md index 04e3b146d..2af62fd6e 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCPolicy.md @@ -19,13 +19,13 @@ Set-JCPolicy can display the available parameters per policy if a `PolicyName` o ### ByID (Default) ``` -Set-JCPolicy -PolicyID [-NewName ] [-Values ] +Set-JCPolicy -PolicyID [-NewName ] [-Values ] [-Notes ] [] ``` ### ByName ``` -Set-JCPolicy -PolicyName [-NewName ] [-Values ] +Set-JCPolicy -PolicyName [-NewName ] [-Values ] [-Notes ] [] ``` @@ -108,6 +108,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -Notes +The notes to set on the existing JumpCloud Policy. + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### -PolicyID The ID of the existing JumpCloud Policy to modify 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/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 9869d9c8f..030e3f0e7 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psd1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psd1 @@ -3,161 +3,161 @@ # # Generated by: JumpCloud Solutions Architect Team # -# Generated on: 10/16/2024 +# Generated on: 11/7/2024 # @{ - # Script module or binary module file associated with this manifest. - RootModule = 'JumpCloud.psm1' - - # Version number of this module. - ModuleVersion = '2.14.2' +# Script module or binary module file associated with this manifest. +RootModule = 'JumpCloud.psm1' + +# Version number of this module. +ModuleVersion = '2.14.3' - # Supported PSEditions - # CompatiblePSEditions = @() +# Supported PSEditions +# CompatiblePSEditions = @() - # ID used to uniquely identify this module - GUID = '31c023d1-a901-48c4-90a3-082f91b31646' +# ID used to uniquely identify this module +GUID = '31c023d1-a901-48c4-90a3-082f91b31646' - # Author of this module - Author = 'JumpCloud Solutions Architect Team' +# Author of this module +Author = 'JumpCloud Solutions Architect Team' - # Company or vendor of this module - CompanyName = 'JumpCloud' +# Company or vendor of this module +CompanyName = 'JumpCloud' - # Copyright statement for this module - Copyright = '(c) JumpCloud. All rights reserved.' +# Copyright statement for this module +Copyright = '(c) JumpCloud. All rights reserved.' - # Description of the functionality provided by this module - Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service' +# Description of the functionality provided by this module +Description = 'PowerShell functions to manage a JumpCloud Directory-as-a-Service' - # Minimum version of the PowerShell engine required by this module - PowerShellVersion = '4.0' +# Minimum version of the PowerShell engine required by this module +PowerShellVersion = '4.0' - # Name of the PowerShell host required by this module - # PowerShellHostName = '' +# Name of the PowerShell host required by this module +# PowerShellHostName = '' - # Minimum version of the PowerShell host required by this module - # PowerShellHostVersion = '' +# Minimum version of the PowerShell host required by this module +# PowerShellHostVersion = '' - # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. - # DotNetFrameworkVersion = '' +# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# DotNetFrameworkVersion = '' - # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. - # ClrVersion = '' +# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. +# ClrVersion = '' - # Processor architecture (None, X86, Amd64) required by this module - # ProcessorArchitecture = '' +# Processor architecture (None, X86, Amd64) required by this module +# ProcessorArchitecture = '' - # Modules that must be imported into the global environment prior to importing this module - RequiredModules = @('JumpCloud.SDK.DirectoryInsights', - 'JumpCloud.SDK.V1', - 'JumpCloud.SDK.V2') +# Modules that must be imported into the global environment prior to importing this module +RequiredModules = @('JumpCloud.SDK.DirectoryInsights', + 'JumpCloud.SDK.V1', + 'JumpCloud.SDK.V2') - # Assemblies that must be loaded prior to importing this module - # RequiredAssemblies = @() +# Assemblies that must be loaded prior to importing this module +# RequiredAssemblies = @() - # Script files (.ps1) that are run in the caller's environment prior to importing this module. - # ScriptsToProcess = @() +# Script files (.ps1) that are run in the caller's environment prior to importing this module. +# ScriptsToProcess = @() - # Type files (.ps1xml) to be loaded when importing this module - # TypesToProcess = @() +# Type files (.ps1xml) to be loaded when importing this module +# TypesToProcess = @() - # Format files (.ps1xml) to be loaded when importing this module - # FormatsToProcess = @() +# Format files (.ps1xml) to be loaded when importing this module +# FormatsToProcess = @() - # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess - # NestedModules = @() +# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess +# NestedModules = @() - # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. - FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCGsuiteMember', - 'Add-JCOffice365Member', 'Add-JCRadiusReplyAttribute', - 'Add-JCSystemGroupMember', 'Add-JCSystemUser', - 'Add-JCUserGroupMember', 'Backup-JCOrganization', 'Connect-JCOnline', - 'Copy-JCAssociation', 'Get-JCAdmin', 'Get-JCAssociation', - 'Get-JCBackup', 'Get-JCCloudDirectory', 'Get-JCCommand', - 'Get-JCCommandResult', 'Get-JCCommandTarget', 'Get-JCEvent', - 'Get-JCEventCount', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', - 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', - 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', - 'Get-JCRadiusServer', 'Get-JCScheduledUserstate', 'Get-JCSystem', - 'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', - 'Get-JCSystemKB', 'Get-JCSystemUser', 'Get-JCUser', - 'Get-JCUserGroupMember', 'Import-JCCommand', 'Import-JCMSPFromCSV', - 'Import-JCUsersFromCSV', 'Invoke-JCCommand', 'Invoke-JCDeployment', - 'New-JCCommand', 'New-JCDeploymentTemplate', 'New-JCImportTemplate', - 'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer', - 'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup', - 'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult', - 'Remove-JCCommandTarget', 'Remove-JCGsuiteMember', - 'Remove-JCOffice365Member', 'Remove-JCPolicy', - 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', - 'Remove-JCSystem', 'Remove-JCSystemGroup', - 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', - 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', - 'Send-JCPasswordReset', 'Set-JCCloudDirectory', 'Set-JCCommand', - 'Set-JCOrganization', 'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', - 'Set-JCRadiusServer', 'Set-JCSettingsFile', 'Set-JCSystem', - 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', - 'Update-JCModule', 'Update-JCMSPFromCSV', 'Update-JCUsersFromCSV' +# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. +FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget', 'Add-JCGsuiteMember', + 'Add-JCOffice365Member', 'Add-JCRadiusReplyAttribute', + 'Add-JCSystemGroupMember', 'Add-JCSystemUser', + 'Add-JCUserGroupMember', 'Backup-JCOrganization', 'Connect-JCOnline', + 'Copy-JCAssociation', 'Get-JCAdmin', 'Get-JCAssociation', + 'Get-JCBackup', 'Get-JCCloudDirectory', 'Get-JCCommand', + 'Get-JCCommandResult', 'Get-JCCommandTarget', 'Get-JCEvent', + 'Get-JCEventCount', 'Get-JCGroup', 'Get-JCOrganization', 'Get-JCPolicy', + 'Get-JCPolicyResult', 'Get-JCPolicyTargetGroup', + 'Get-JCPolicyTargetSystem', 'Get-JCRadiusReplyAttribute', + 'Get-JCRadiusServer', 'Get-JCScheduledUserstate', 'Get-JCSystem', + 'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights', + 'Get-JCSystemKB', 'Get-JCSystemUser', 'Get-JCUser', + 'Get-JCUserGroupMember', 'Import-JCCommand', 'Import-JCMSPFromCSV', + 'Import-JCUsersFromCSV', 'Invoke-JCCommand', 'Invoke-JCDeployment', + 'New-JCCommand', 'New-JCDeploymentTemplate', 'New-JCImportTemplate', + 'New-JCMSPImportTemplate', 'New-JCPolicy', 'New-JCRadiusServer', + 'New-JCSystemGroup', 'New-JCUser', 'New-JCUserGroup', + 'Remove-JCAssociation', 'Remove-JCCommand', 'Remove-JCCommandResult', + 'Remove-JCCommandTarget', 'Remove-JCGsuiteMember', + 'Remove-JCOffice365Member', 'Remove-JCPolicy', + 'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer', + 'Remove-JCSystem', 'Remove-JCSystemGroup', + 'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser', + 'Remove-JCUserGroup', 'Remove-JCUserGroupMember', + 'Send-JCPasswordReset', 'Set-JCCloudDirectory', 'Set-JCCommand', + 'Set-JCOrganization', 'Set-JCPolicy', 'Set-JCRadiusReplyAttribute', + 'Set-JCRadiusServer', 'Set-JCSettingsFile', 'Set-JCSystem', + 'Set-JCSystemUser', 'Set-JCUser', 'Set-JCUserGroupLDAP', + 'Update-JCModule', 'Update-JCMSPFromCSV', 'Update-JCUsersFromCSV' - # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. - CmdletsToExport = @() +# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. +CmdletsToExport = @() - # Variables to export from this module - VariablesToExport = '*' +# Variables to export from this module +VariablesToExport = '*' - # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. - AliasesToExport = 'New-JCAssociation' +# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. +AliasesToExport = 'New-JCAssociation' - # DSC resources to export from this module - # DscResourcesToExport = @() +# DSC resources to export from this module +# DscResourcesToExport = @() - # List of all modules packaged with this module - # ModuleList = @() +# List of all modules packaged with this module +# ModuleList = @() - # List of all files packaged with this module - # FileList = @() +# List of all files packaged with this module +# FileList = @() - # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. - PrivateData = @{ +# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. +PrivateData = @{ - PSData = @{ + PSData = @{ - # Tags applied to this module. These help with module discovery in online galleries. - Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' + # Tags applied to this module. These help with module discovery in online galleries. + Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory' - # A URL to the license for this module. - LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' + # A URL to the license for this module. + LicenseUri = 'https://github.com/TheJumpCloud/support/blob/master/PowerShell/LICENSE' - # A URL to the main website for this project. - ProjectUri = 'https://github.com/TheJumpCloud/support/wiki' + # A URL to the main website for this project. + ProjectUri = 'https://github.com/TheJumpCloud/support/wiki' - # A URL to an icon representing this module. - IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4' + # A URL to an icon representing this module. + IconUri = 'https://avatars1.githubusercontent.com/u/4927461?s=200&v=4' - # ReleaseNotes of this module - ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes' + # ReleaseNotes of this module + ReleaseNotes = 'https://git.io/jc-pwsh-releasenotes' - # Prerelease string of this module - # Prerelease = '' + # Prerelease string of this module + # Prerelease = '' - # Flag to indicate whether the module requires explicit user acceptance for install/update/save - # RequireLicenseAcceptance = $false + # Flag to indicate whether the module requires explicit user acceptance for install/update/save + # RequireLicenseAcceptance = $false - # External dependent modules of this module - # ExternalModuleDependencies = @() + # External dependent modules of this module + # ExternalModuleDependencies = @() - } # End of PSData hashtable - - } # End of PrivateData hashtable + } # End of PSData hashtable + +} # End of PrivateData hashtable - # HelpInfo URI of this module - HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' +# HelpInfo URI of this module +HelpInfoURI = 'https://github.com/TheJumpCloud/support/wiki' - # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. - # DefaultCommandPrefix = '' +# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. +# DefaultCommandPrefix = '' } diff --git a/PowerShell/JumpCloud Module/JumpCloud.psm1 b/PowerShell/JumpCloud Module/JumpCloud.psm1 index 83bd92488..17c34bd6c 100644 --- a/PowerShell/JumpCloud Module/JumpCloud.psm1 +++ b/PowerShell/JumpCloud Module/JumpCloud.psm1 @@ -25,13 +25,13 @@ $PSDefaultParameterValues['Invoke-WebRequest:ContentType'] = 'application/json; If ($PSVersionTable.PSEdition -eq 'Core') { $PSDefaultParameterValues['Invoke-RestMethod:SkipCertificateCheck'] = $true $PSDefaultParameterValues['Invoke-RestMethod:SkipHeaderValidation'] = $true - $PSDefaultParameterValues['Invoke-RestMethod:MaximumRetryCount'] = 5 - $PSDefaultParameterValues['Invoke-RestMethod:RetryIntervalSec'] = 5 + $PSDefaultParameterValues['Invoke-RestMethod:MaximumRetryCount'] = 1 + $PSDefaultParameterValues['Invoke-RestMethod:RetryIntervalSec'] = 1 $PSDefaultParameterValues['Invoke-WebRequest:SkipCertificateCheck'] = $true $PSDefaultParameterValues['Invoke-WebRequest:SkipHeaderValidation'] = $true - $PSDefaultParameterValues['Invoke-WebRequest:MaximumRetryCount'] = 5 - $PSDefaultParameterValues['Invoke-WebRequest:RetryIntervalSec'] = 5 + $PSDefaultParameterValues['Invoke-WebRequest:MaximumRetryCount'] = 1 + $PSDefaultParameterValues['Invoke-WebRequest:RetryIntervalSec'] = 1 } Else { #Ignore SSL errors / do not add policy if it exists if (-Not [System.Net.ServicePointManager]::CertificatePolicy) { diff --git a/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCObject.ps1 b/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCObject.ps1 index 4ea262ca0..aabaa0911 100755 --- a/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCObject.ps1 +++ b/PowerShell/JumpCloud Module/Private/NestedFunctions/Get-JCObject.ps1 @@ -273,10 +273,10 @@ Function Get-JCObject { Write-Error ('$Type of "' + $Type + '" not found. $Type must be:' + ($JCType.TypeName.TypeNameSingular -join ',')) } } Catch { - Write-Error ($_) + Throw ($_) } } End { Return $Results } -} \ No newline at end of file +} diff --git a/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 b/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 index 07f9add8a..2f427149c 100755 --- a/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 +++ b/PowerShell/JumpCloud Module/Public/Authentication/Connect-JCOnline.ps1 @@ -11,7 +11,6 @@ Function Connect-JCOnline () { 'Position' = 1; 'ValueFromPipelineByPropertyName' = $true; 'ValidateNotNullOrEmpty' = $true; - 'ValidateLength' = (40, 40); 'HelpMessage' = 'Please enter your JumpCloud API key. This can be found in the JumpCloud admin console within "API Settings" accessible from the drop down icon next to the admin email address in the top right corner of the JumpCloud admin console.'; } $Param_JumpCloudOrgId = @{ @@ -104,17 +103,21 @@ Function Connect-JCOnline () { $global:JCAPIKEY = $env:JCApiKey } # Set $env:JCOrgId in Set-JCOrganization - $Auth = If ([System.String]::IsNullOrEmpty($JumpCloudOrgId) -and [System.String]::IsNullOrEmpty($env:JCOrgId)) { - Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) - } ElseIf (-not [System.String]::IsNullOrEmpty($JumpCloudOrgId) -and [System.String]::IsNullOrEmpty($env:JCOrgId)) { - Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($JumpCloudOrgId) - } ElseIf ([System.String]::IsNullOrEmpty($JumpCloudOrgId) -and -not [System.String]::IsNullOrEmpty($env:JCOrgId)) { - Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($env:JCOrgId) - } ElseIf (-not [System.String]::IsNullOrEmpty($JumpCloudOrgId) -and -not [System.String]::IsNullOrEmpty($env:JCOrgId) -and $JumpCloudOrgId -ne $env:JCOrgId) { - Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($JumpCloudOrgId) - } Else { - Write-Debug ('The $JumpCloudOrgId supplied matches existing $env:JCOrgId.') - Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($env:JCOrgId) + try { + $Auth = If ([System.String]::IsNullOrEmpty($JumpCloudOrgId) -and [System.String]::IsNullOrEmpty($env:JCOrgId)) { + Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -ErrorVariable api_err + } ElseIf (-not [System.String]::IsNullOrEmpty($JumpCloudOrgId) -and [System.String]::IsNullOrEmpty($env:JCOrgId)) { + Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($JumpCloudOrgId) -ErrorVariable api_err + } ElseIf ([System.String]::IsNullOrEmpty($JumpCloudOrgId) -and -not [System.String]::IsNullOrEmpty($env:JCOrgId)) { + Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($env:JCOrgId) -ErrorVariable api_err + } ElseIf (-not [System.String]::IsNullOrEmpty($JumpCloudOrgId) -and -not [System.String]::IsNullOrEmpty($env:JCOrgId) -and $JumpCloudOrgId -ne $env:JCOrgId) { + Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($JumpCloudOrgId) -ErrorVariable api_err + } Else { + Write-Debug ('The $JumpCloudOrgId supplied matches existing $env:JCOrgId.') + Set-JCOrganization -JumpCloudApiKey:($env:JCApiKey) -JumpCloudOrgId:($env:JCOrgId) -ErrorVariable api_err + } + } catch { + Write-Verbose "Error: Unable to validate API Key" } If (-not [System.String]::IsNullOrEmpty($Auth)) { # Each time a new org is selected get settings info @@ -194,7 +197,7 @@ Function Connect-JCOnline () { # 'JCOrgName' = $Auth.JCOrgName; # } } Else { - Write-Error ('Unable to set module authentication') + Write-Verbose "Error: Unable to set module authentication" } # set Argument Completer(s) which require authentication $templates = Get-JCSDKPolicyTemplate @@ -215,9 +218,9 @@ Function Connect-JCOnline () { } } Catch { - Write-Error $_ + Throw "Unable to authenticate: $_" } } End { } -} \ No newline at end of file +} diff --git a/PowerShell/JumpCloud Module/Public/Authentication/Set-JCOrganization.ps1 b/PowerShell/JumpCloud Module/Public/Authentication/Set-JCOrganization.ps1 index 938e9e116..b71c66735 100644 --- a/PowerShell/JumpCloud Module/Public/Authentication/Set-JCOrganization.ps1 +++ b/PowerShell/JumpCloud Module/Public/Authentication/Set-JCOrganization.ps1 @@ -31,7 +31,11 @@ Function Set-JCOrganization { If ((-not [System.String]::IsNullOrEmpty($JumpCloudApiKey) -and -not [System.String]::IsNullOrEmpty($env:JCApiKey)) -and $JumpCloudApiKey -eq $env:JCApiKey) { Write-Verbose ("Parameter Set: $($PSCmdlet.ParameterSetName)") Write-Verbose ('Populating JCOrganizations') - $Organizations = Get-JCObject -Type:('organization') -Fields:('_id', 'displayName') + try { + $Organizations = Get-JCObject -Type:('organization') -Fields:('_id', 'displayName') -ErrorVariable api_err + } catch { + Throw + } If (-not [System.String]::IsNullOrEmpty($Organizations)) { If ($Organizations.Count -gt 1) { # If not JumpCloudOrgId was specified or if the specified JumpCloudOrgId does not exist within the list of available organizations prompt for selection @@ -93,4 +97,4 @@ Function Set-JCOrganization { } End { } -} \ No newline at end of file +} diff --git a/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 b/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 index c10fdff42..0ce354b35 100755 --- a/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 +++ b/PowerShell/JumpCloud Module/Public/Policies/Get-JCPolicy.ps1 @@ -80,7 +80,7 @@ Function Get-JCPolicy () { } End { If ($Results) { - Return $Results | Select-Object -Property "name", "id", "templateID", "values", "template" + Return $Results | Select-Object -Property "name", "id", "templateID", "values", "template", "notes" } } } \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 b/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 index 0611c7751..17e650145 100644 --- a/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 +++ b/PowerShell/JumpCloud Module/Public/Policies/New-JCPolicy.ps1 @@ -19,7 +19,11 @@ function New-JCPolicy { [Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The values object either built manually or passed in through Get-JCPolicy')] [System.object[]] - $Values + $Values, + [Parameter(Mandatory = $false, + HelpMessage = 'The notes of the policy to create.')] + [System.String] + $Notes ) DynamicParam { if ($PSBoundParameters["TemplateID"]) { @@ -125,7 +129,7 @@ function New-JCPolicy { $requiredSet = @('TemplateID', 'TemplateName', 'Name' , 'Values') foreach ($parameter in $paramterSet) { $parameterComparison = Compare-Object -ReferenceObject $requiredSet -DifferenceObject $parameter - if ($parameterComparison | Where-Object { $_.sideindicator -eq "=>" }) { + if ($parameterComparison | Where-Object { ( $_.sideindicator -eq "=>") -And ($_.InputObject -ne "Notes") }) { $DynamicParamSet = $true break } @@ -268,12 +272,14 @@ function New-JCPolicy { name = $policyName template = @{id = $templateID } values = @($updatedPolicyObject) + notes = $Notes } | ConvertTo-Json -Depth 99 } else { # for policies w/o payloads, just pass in the name & template $body = [PSCustomObject]@{ name = $policyName template = @{id = $templateID } + notes = $Notes } | ConvertTo-Json -Depth 99 } @@ -290,6 +296,6 @@ function New-JCPolicy { } end { - return $response | Select-Object -Property "name", "id", "templateID", "values", "template" + return $response | Select-Object -Property "name", "id", "templateID", "values", "template", "notes" } } \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 b/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 index f517e7f2f..63f8eccce 100644 --- a/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 +++ b/PowerShell/JumpCloud Module/Public/Policies/Set-JCPolicy.ps1 @@ -22,7 +22,11 @@ function Set-JCPolicy { [Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The values object either built manually or passed in through Get-JCPolicy')] [System.object[]] - $Values + $Values, + [Parameter(Mandatory = $false, + HelpMessage = 'The notes to set on the existing JumpCloud Policy.')] + [System.String] + $Notes ) DynamicParam { @@ -161,11 +165,20 @@ function Set-JCPolicy { $requiredSet = @('PolicyID', 'PolicyName', 'NewName' , 'Values') foreach ($parameter in $paramterSet) { $parameterComparison = Compare-Object -ReferenceObject $requiredSet -DifferenceObject $parameter - if ($parameterComparison | Where-Object { $_.sideindicator -eq "=>" }) { + if ($parameterComparison | Where-Object { ( $_.sideindicator -eq "=>") -And ($_.InputObject -ne "Notes") }) { $DynamicParamSet = $true break } } + # only update newName or Notes: + if ((("NewName" -in $params.keys) -AND ("Values" -notin $params.Keys)) -OR + (("Notes" -in $params.keys) -AND ("Values" -notin $params.Keys))) { + $Values = $foundPolicy.values + } + # get the notes if it's not in the param set + if (-not $PSBoundParameters["Notes"]) { + $Notes = $foundPolicy.Notes + } if ($DynamicParamSet) { # begin dynamic param set $newObject = New-Object System.Collections.ArrayList @@ -318,11 +331,13 @@ function Set-JCPolicy { name = $policyNameFromProcess template = @{id = $foundPolicy.Template.Id } values = @($updatedPolicyObject) + notes = $Notes } | ConvertTo-Json -Depth 99 } else { $body = [PSCustomObject]@{ name = $policyNameFromProcess template = @{id = $foundPolicy.Template.Id } + notes = $Notes } | ConvertTo-Json -Depth 99 } $headers = @{ @@ -336,6 +351,6 @@ function Set-JCPolicy { } } end { - return $response | Select-Object -Property "name", "id", "templateID", "values", "template" + return $response | Select-Object -Property "name", "id", "templateID", "values", "template", "notes" } } diff --git a/PowerShell/JumpCloud Module/Tests/HelperFunctions.ps1 b/PowerShell/JumpCloud Module/Tests/HelperFunctions.ps1 index 82092dc41..ce63adfd6 100755 --- a/PowerShell/JumpCloud Module/Tests/HelperFunctions.ps1 +++ b/PowerShell/JumpCloud Module/Tests/HelperFunctions.ps1 @@ -138,4 +138,37 @@ Function New-RandomStringLower () { $Random = -join ((65..90) + (97..122) | Get-Random -Count $NumberOfChars | ForEach-Object { [char]$_ }) } end { Return $Random.ToLower() } -} \ No newline at end of file +} + +function Create-RadiusServerTryCatch { + [CmdletBinding()] + param ( + [Parameter()] + [System.Object] + $RadiusDefinition + ) + begin { + $catch_counter = 0 + } + process { + do { + $RadiusServerBuilt = $false + try { + Write-Host "Creating Radius Server with IP: $($RadiusDefinition.networkSourceIp)..." + $radiusServer = New-JCRadiusServer @RadiusDefinition + if ($radiusServer) { + $RadiusServerBuilt = $true + } else { + break + } + } catch { + Write-Host "$_" + $RadiusDefinition.networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString + Write-Host "Creating Radius Server with NEW IP: $($RadiusDefinition.networkSourceIp)..." + } + } until ($RadiusServerBuilt) + } + end { + return $radiusServer + } +} diff --git a/PowerShell/JumpCloud Module/Tests/Public/Policies/Get-JCPolicy.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Policies/Get-JCPolicy.Tests.ps1 index a0cc8cbed..6bbb1c601 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Policies/Get-JCPolicy.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Policies/Get-JCPolicy.Tests.ps1 @@ -39,8 +39,9 @@ Describe -Tag:('JCPolicy') 'Get-JCPolicy 1.10' { $SingleResult = Get-JCPolicy -Name:($PesterParams_SinglePolicy.Name) $SingleResult.name | Should -Not -BeNullOrEmpty $SingleResult.id | Should -Not -BeNullOrEmpty - $SingleResult.values | Should -BeNullOrEmpty $SingleResult.template | Should -Not -BeNullOrEmpty $SingleResult.templateID | Should -Not -BeNullOrEmpty + # notes should be returned + $SingleResult.notes.PSObject.Properties | Should -BeTrue } } 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 f0e700439..e53437490 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Policies/New-JCPolicy.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Policies/New-JCPolicy.Tests.ps1 @@ -1,7 +1,5 @@ Describe -Tag:('JCPolicy') 'New-JCPolicy' { BeforeAll { - - $policies = Get-JCPolicy $policies | Where-Object { $_.Name -like "Pester -*" } | ForEach-Object { Remove-JcSdkPolicy -Id $_.id } $policyTemplates = Get-JcSdkPolicyTemplate @@ -281,22 +279,23 @@ Describe -Tag:('JCPolicy') 'New-JCPolicy' { Context 'New-JCPolicy should reutrn policies with the correct data types' { It 'New-JCPolicy returns expected parameters' { $usbTemplateLinux = $policyTemplates | Where-Object { $_.name -eq "disable_usb_storage_linux" } - $usbLinuxPolicy = New-JCPolicy -TemplateID $usbTemplateLinux.Id -Name "Pester - USB Linux $(new-randomString -NumberOfChars 8)" + $usbLinuxPolicy = New-JCPolicy -TemplateID $usbTemplateLinux.Id -Name "Pester - USB Linux $(new-randomString -NumberOfChars 8)" -disable_mtp $true -disable_afc $false -disable_mmc $false -Notes "usb" $usbLinuxPolicy.name | Should -Not -BeNullOrEmpty $usbLinuxPolicy.id | Should -Not -BeNullOrEmpty - $usbLinuxPolicy.values | Should -BeNullOrEmpty $usbLinuxPolicy.template | Should -Not -BeNullOrEmpty $usbLinuxPolicy.templateID | Should -Not -BeNullOrEmpty + $usbLinuxPolicy.notes | Should -Be "usb" } } Context 'Create new policy using Registry file' { It 'New-JCPolicy using regFilePath parameter' { - $registryPolicy = New-JCPolicy -Name 'Pester - RegFileUpload' -templateID '5f07273cb544065386e1ce6f' -registryFile $PesterParams_RegistryFilePath + $registryPolicy = New-JCPolicy -Name 'Pester - RegFileUpload' -templateID '5f07273cb544065386e1ce6f' -registryFile $PesterParams_RegistryFilePath -Notes "regfile" $registryPolicy.name | Should -Not -BeNullOrEmpty $registryPolicy.templateID | Should -Be '5f07273cb544065386e1ce6f' $registryPolicy.values | Should -Not -BeNullOrEmpty $registryPolicy.id | Should -Not -BeNullOrEmpty $registryPolicy.template | Should -Not -BeNullOrEmpty + $registryPolicy.notes | Should -Be "regfile" } } Context 'Manual Test Cases' -Skip { diff --git a/PowerShell/JumpCloud Module/Tests/Public/Policies/Set-JCPolicy.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Policies/Set-JCPolicy.Tests.ps1 index b78beb5d9..2e6d8cc43 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Policies/Set-JCPolicy.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Policies/Set-JCPolicy.Tests.ps1 @@ -477,21 +477,22 @@ Describe -Tag:('JCPolicy') 'Set-JCPolicy' { Context 'Set-JCPolicy should reutrn policies with the correct data types' { It 'Set-JCPolicy returns expected parameters' { $registryTemplate = $policyTemplates | Where-Object { $_.name -eq "disable_usb_storage_linux" } - $usbLinuxPolicy = New-JCPolicy -TemplateID $registryTemplate.Id -Name "Pester - USB Linux $(new-randomString -NumberOfChars 8)" - $usbLinuxPolicyUpdated = Set-JCPolicy -PolicyId $usbLinuxPolicy.Id -NewName "Pester - USB Linux $(new-randomString -NumberOfChars 8)" + $usbLinuxPolicy = New-JCPolicy -TemplateID $registryTemplate.Id -Name "Pester - USB Linux $(new-randomString -NumberOfChars 8)" -disable_mtp $true -disable_afc $false -disable_mmc $false + $usbLinuxPolicyUpdated = Set-JCPolicy -PolicyId $usbLinuxPolicy.Id -NewName "Pester - USB Linux $(new-randomString -NumberOfChars 8)" -Notes "usb" $usbLinuxPolicyUpdated.name | Should -Not -BeNullOrEmpty $usbLinuxPolicyUpdated.id | Should -Not -BeNullOrEmpty - $usbLinuxPolicyUpdated.values | Should -BeNullOrEmpty $usbLinuxPolicyUpdated.template | Should -Not -BeNullOrEmpty $usbLinuxPolicyUpdated.templateID | Should -Not -BeNullOrEmpty + $usbLinuxPolicy.Notes | Should -BeNullOrEmpty + $usbLinuxPolicyUpdated.Notes | Should -Be "usb" } } Context 'Validates Throw Conditions' { It 'Should throw an error when multiple policies with the same name exist and the policyName param is specified' { $registryTemplate = $policyTemplates | Where-Object { $_.name -eq "disable_usb_storage_linux" } $randomValue = $(new-randomString -NumberOfChars 8) - $usbLinuxPolicy = New-JCPolicy -TemplateID $registryTemplate.Id -Name "Pester - USB Linux $($randomValue)" - $usbLinuxPolicy = New-JCPolicy -TemplateID $registryTemplate.Id -Name "Pester - USB Linux $($randomValue)" + $usbLinuxPolicy = New-JCPolicy -TemplateID $registryTemplate.Id -Name "Pester - USB Linux $($randomValue)" -disable_mtp $true -disable_afc $false -disable_mmc $false + $usbLinuxPolicy = New-JCPolicy -TemplateID $registryTemplate.Id -Name "Pester - USB Linux $($randomValue)" -disable_mtp $true -disable_afc $false -disable_mmc $false { Set-JCPolicy -PolicyName -Name "Pester - USB Linux $($randomValue)" -NewName "Pester - USB Linux $(new-randomString -NumberOfChars 8)" } | Should -Throw } @@ -614,4 +615,4 @@ Describe -Tag:('JCPolicy') 'Set-JCPolicy' { $updatedPolicy.values.value[0].customValueName | Should -Not -Be $policyValue.customValueName } } -} \ No newline at end of file +} diff --git a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Get-JCRadiusServer.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Get-JCRadiusServer.Tests.ps1 index d3bf04e2f..52ec42bfe 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Get-JCRadiusServer.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Get-JCRadiusServer.Tests.ps1 @@ -1,6 +1,14 @@ Describe -Tag:('JCRadiusServer') 'Get-JCRadiusServer Tests' { BeforeAll { - $RadiusServerTemplate = Get-JCRadiusServer -Name:($PesterParams_RadiusServer.name); # -Fields:('') -Filter:('') -Limit:(1) -Skip:(1) -Paginate:($true) -Force; + $NewRadiusServer = @{ + networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString + sharedSecret = "$(Get-Random)" + name = "PesterTest_RadiusServer_$(Get-Random)" + authIdp = 'JUMPCLOUD' + + }; + + $RadiusServerTemplate = Create-RadiusServerTryCatch $NewRadiusServer } Context 'Get-JCRadiusServer' { It ('Should return all radius servers.') { diff --git a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/New-JCRadiusServer.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/New-JCRadiusServer.Tests.ps1 index cc80825ac..235b9e5cd 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/New-JCRadiusServer.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/New-JCRadiusServer.Tests.ps1 @@ -1,7 +1,21 @@ Describe -Tag:('JCRadiusServer') 'New-JCRadiusServer Tests' { BeforeAll { - $RadiusServerTemplate = Get-JCRadiusServer -Name:($PesterParams_RadiusServer.name); # -Fields:('') -Filter:('') -Limit:(1) -Skip:(1) -Paginate:($true) -Force; - $AzureRadiusServerTemplate = Get-JCRadiusServer -Name:($PesterParams_RadiusAzureServer.name); # -Fields:('') -Filter:('') -Limit:(1) -Skip:(1) -Paginate:($true) -Force; + $NewRadiusServer = @{ + networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString + sharedSecret = "$(Get-Random)" + name = "PesterTest_RadiusServer_$(Get-Random)" + authIdp = 'JUMPCLOUD' + + }; + $NewAzureRadiusServer = @{ + networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString + sharedSecret = "$(Get-Random)" + name = "PesterTest_AzureRadiusServer_$(Get-Random)" + authIdp = 'AZURE' + }; + + $RadiusServerTemplate = Create-RadiusServerTryCatch $NewRadiusServer + $AzureRadiusServerTemplate = Create-RadiusServerTryCatch $NewAzureRadiusServer } Context 'New-JCRadiusServer' { It ('Should create a new radius server.') { @@ -21,4 +35,4 @@ Describe -Tag:('JCRadiusServer') 'New-JCRadiusServer Tests' { Remove-JCRadiusServer -id $AzureRadiusServer.id -Force } } -} \ No newline at end of file +} diff --git a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Remove-JCRadiusServer.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Remove-JCRadiusServer.Tests.ps1 index 938096142..98ff76eb3 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Remove-JCRadiusServer.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Remove-JCRadiusServer.Tests.ps1 @@ -1,15 +1,19 @@ Describe -Tag:('JCRadiusServer') 'Remove-JCRadiusServer Tests' { BeforeAll { - $PesterParams_RadiusServer = Get-JCRadiusServer -Name:($PesterParams_RadiusServer.name) - If (-not $PesterParams_RadiusServer) { - $PesterParams_RadiusServer = New-JCRadiusServer @PesterParams_NewRadiusServer - } + $NewRadiusServer = @{ + networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString + sharedSecret = "$(Get-Random)" + name = "PesterTest_RadiusServer_$(Get-Random)" + authIdp = 'JUMPCLOUD' + + }; + $RadiusServerTemplate = Create-RadiusServerTryCatch $NewRadiusServer } Context 'Remove-JCRadiusServer' { It ('Should remove a specific radius server.') { - $RadiusServer = Remove-JCRadiusServer -Id:($PesterParams_RadiusServer.id) -Force; + $RadiusServer = Remove-JCRadiusServer -Id:($RadiusServerTemplate.id) -Force; $RadiusServer | Should -Not -BeNullOrEmpty - $RadiusServer.name | Should -Be $PesterParams_RadiusServer.name + $RadiusServer.name | Should -Be $RadiusServerTemplate.name } } -} \ No newline at end of file +} diff --git a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Set-JCRadiusServer.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Set-JCRadiusServer.Tests.ps1 index 9890c7b7a..de2f5f1cb 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Set-JCRadiusServer.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/RadiusServer/Set-JCRadiusServer.Tests.ps1 @@ -1,120 +1,99 @@ Describe -Tag:('JCRadiusServer') 'Set-JCRadiusServer Tests' { BeforeAll { - $PesterParams_RadiusServer = Get-JCRadiusServer -Name:($PesterParams_RadiusServer.name) - If (-not $PesterParams_RadiusServer) { - try { - $PesterParams_RadiusServer = New-JCRadiusServer @PesterParams_NewRadiusServer - } catch { - $PesterParams_NewRadiusServer = @{ - networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString - sharedSecret = 'f3TkHSK2GT4JR!W9tugRPp2zQnAVObv' - name = 'PesterTest_RadiusServer' - }; - $PesterParams_RadiusServer = New-JCRadiusServer @PesterParams_NewRadiusServer - } - } + $NewRadiusServer = @{ + networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString + sharedSecret = "$(Get-Random)" + name = "PesterTest_RadiusServer_$(Get-Random)" + authIdp = 'JUMPCLOUD' + + }; + + $RadiusServerTemplate = Create-RadiusServerTryCatch $NewRadiusServer + } Context 'Set-JCRadiusServer' { It ('Should update a radius server ByName.') { - $RadiusServer = Set-JCRadiusServer -Name:($PesterParams_RadiusServer.name) -newName:('Something') -networkSourceIp:($PesterParams_networkSourceIpUpdate) -sharedSecret:('kldFaSDfAdgfAgxcxWEQTRDS') -Force; + $RadiusServer = Set-JCRadiusServer -Name:($RadiusServerTemplate.name) -newName:('Something') -sharedSecret:('kldFaSDfAdgfAgxcxWEQTRDS') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.name | Should -Be 'Something' - $RadiusServer.networkSourceIp | Should -Be $PesterParams_networkSourceIpUpdate $RadiusServer.sharedSecret | Should -Be 'kldFaSDfAdgfAgxcxWEQTRDS' } It ('Should update a radius server ById.') { - $RadiusServer = Set-JCRadiusServer -Id:($PesterParams_RadiusServer.id) -newName:('SomethingElse') -networkSourceIp:($PesterParams_networkSourceIpInitial) -sharedSecret:('aseRDGsDFGSDfgBsdRFTygSW') -Force; + $RadiusServer = Set-JCRadiusServer -Id:($RadiusServerTemplate.id) -newName:('SomethingElse') -sharedSecret:('aseRDGsDFGSDfgBsdRFTygSW') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.name | Should -Be 'SomethingElse' - $RadiusServer.networkSourceIp | Should -Be $PesterParams_networkSourceIpInitial $RadiusServer.sharedSecret | Should -Be 'aseRDGsDFGSDfgBsdRFTygSW' } - # It ('Should return a specific radius server ByValue (ById).') { - # $RadiusServer = Set-JCRadiusServer -SearchBy:('ById') -SearchByValue:('') -newName:('') -networkSourceIp:('') -sharedSecret:('') -Force; - # $RadiusServer | Should -Not -BeNullOrEmpty - # $RadiusServer.id | Should -Be $PesterParams_RadiusServer.id - # } - # It ('Should return a specific radius server ByValue (ByName).') { - # $RadiusServer = Set-JCRadiusServer -SearchBy:('ByName') -SearchByValue:('') -newName:('') -networkSourceIp:('') -sharedSecret:('') -Force; - # $RadiusServer | Should -Not -BeNullOrEmpty - # $RadiusServer.name | Should -Be $PesterParams_RadiusServer.name - # } } } Describe -Tag:('JCRadiusServer') 'Set-JCRadiusServer 1.15.3' { BeforeAll { - $PesterParams_RadiusServer = Get-JCRadiusServer -Name:($PesterParams_RadiusServer.name) - If (-not $PesterParams_RadiusServer) { - try { - $PesterParams_RadiusServer = New-JCRadiusServer @PesterParams_NewRadiusServer - } catch { - $PesterParams_NewRadiusServer = @{ - networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString - sharedSecret = 'f3TkHSK2GT4JR!W9tugRPp2zQnAVObv' - name = 'PesterTest_RadiusServer' - }; - $PesterParams_RadiusServer = New-JCRadiusServer @PesterParams_NewRadiusServer - } - } + $NewRadiusServer = @{ + networkSourceIp = [IPAddress]::Parse([String](Get-Random)).IPAddressToString + sharedSecret = "$(Get-Random)" + name = "PesterTest_RadiusServer_$(Get-Random)" + authIdp = 'JUMPCLOUD' + }; + $RadiusServerTemplate = Create-RadiusServerTryCatch $NewRadiusServer } Context 'Set-JCRadiusServer params' { It ('Should ENABLE mfa on a radius server by ByName.') { - $RadiusServer = Set-JCRadiusServer -Name:($PesterParams_RadiusServer.name) -mfa:('ENABLED') -Force; + $RadiusServer = Set-JCRadiusServer -Name:($RadiusServerTemplate.name) -mfa:('ENABLED') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.mfa | Should -Be 'ENABLED' } It ('Should DISABLE mfa on a radius server by ByName.') { - $RadiusServer = Set-JCRadiusServer -Name:($PesterParams_RadiusServer.name) -mfa:('DISABLED') -Force; + $RadiusServer = Set-JCRadiusServer -Name:($RadiusServerTemplate.name) -mfa:('DISABLED') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.mfa | Should -Be 'DISABLED' } It ('Should ENABLE mfa on a radius server by ID.') { - $RadiusServer = Set-JCRadiusServer -id:($PesterParams_RadiusServer.id) -mfa:('ENABLED') -Force; + $RadiusServer = Set-JCRadiusServer -id:($RadiusServerTemplate.id) -mfa:('ENABLED') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.mfa | Should -Be 'ENABLED' } It ('Should DISABLE mfa on a radius server by ID.') { - $RadiusServer = Set-JCRadiusServer -id:($PesterParams_RadiusServer.id) -mfa:('DISABLED') -Force; + $RadiusServer = Set-JCRadiusServer -id:($RadiusServerTemplate.id) -mfa:('DISABLED') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.mfa | Should -Be 'DISABLED' } It ('Should set userLockoutAction to REMOVE on a radius server by ByName.') { - $RadiusServer = Set-JCRadiusServer -Name:($PesterParams_RadiusServer.name) -userLockoutAction:('REMOVE') -Force; + $RadiusServer = Set-JCRadiusServer -Name:($RadiusServerTemplate.name) -userLockoutAction:('REMOVE') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userLockoutAction | Should -Be 'REMOVE' } It ('Should set userLockoutAction to MAINTAIN on a radius server by ByName.') { - $RadiusServer = Set-JCRadiusServer -Name:($PesterParams_RadiusServer.name) -userLockoutAction:('MAINTAIN') -Force; + $RadiusServer = Set-JCRadiusServer -Name:($RadiusServerTemplate.name) -userLockoutAction:('MAINTAIN') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userLockoutAction | Should -Be 'MAINTAIN' } It ('Should set userLockoutAction to REMOVE on a radius server by id.') { - $RadiusServer = Set-JCRadiusServer -id:($PesterParams_RadiusServer.id) -userLockoutAction:('REMOVE') -Force; + $RadiusServer = Set-JCRadiusServer -id:($RadiusServerTemplate.id) -userLockoutAction:('REMOVE') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userLockoutAction | Should -Be 'REMOVE' } It ('Should set userLockoutAction to MAINTAIN on a radius server by id.') { - $RadiusServer = Set-JCRadiusServer -id:($PesterParams_RadiusServer.id) -userLockoutAction:('MAINTAIN') -Force; + $RadiusServer = Set-JCRadiusServer -id:($RadiusServerTemplate.id) -userLockoutAction:('MAINTAIN') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userLockoutAction | Should -Be 'MAINTAIN' } It ('Should set userPasswordExpirationAction to REMOVE on a radius server by ByName.') { - $RadiusServer = Set-JCRadiusServer -Name:($PesterParams_RadiusServer.name) -userPasswordExpirationAction:('REMOVE') -Force; + $RadiusServer = Set-JCRadiusServer -Name:($RadiusServerTemplate.name) -userPasswordExpirationAction:('REMOVE') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userPasswordExpirationAction | Should -Be 'REMOVE' } It ('Should set userPasswordExpirationAction to MAINTAIN on a radius server by ByName.') { - $RadiusServer = Set-JCRadiusServer -Name:($PesterParams_RadiusServer.name) -userPasswordExpirationAction:('MAINTAIN') -Force; + $RadiusServer = Set-JCRadiusServer -Name:($RadiusServerTemplate.name) -userPasswordExpirationAction:('MAINTAIN') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userPasswordExpirationAction | Should -Be 'MAINTAIN' } It ('Should set userPasswordExpirationAction to REMOVE on a radius server by id.') { - $RadiusServer = Set-JCRadiusServer -id:($PesterParams_RadiusServer.id) -userPasswordExpirationAction:('REMOVE') -Force; + $RadiusServer = Set-JCRadiusServer -id:($RadiusServerTemplate.id) -userPasswordExpirationAction:('REMOVE') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userPasswordExpirationAction | Should -Be 'REMOVE' } It ('Should set userPasswordExpirationAction to MAINTAIN on a radius server by id.') { - $RadiusServer = Set-JCRadiusServer -id:($PesterParams_RadiusServer.id) -userPasswordExpirationAction:('MAINTAIN') -Force; + $RadiusServer = Set-JCRadiusServer -id:($RadiusServerTemplate.id) -userPasswordExpirationAction:('MAINTAIN') -Force; $RadiusServer | Should -Not -BeNullOrEmpty $RadiusServer.userPasswordExpirationAction | Should -Be 'MAINTAIN' } diff --git a/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Import-JCMSPFromCSV.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Import-JCMSPFromCSV.Tests.ps1 index a0ebf1f71..a915e9bee 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Import-JCMSPFromCSV.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Import-JCMSPFromCSV.Tests.ps1 @@ -1,4 +1,4 @@ -Describe -Tag:('MSP') 'Import-JCMSPFromCSV' { +Describe -Tag:('MSP') 'Import-JCMSPFromCSV' -Skip { BeforeAll { BeforeAll { Connect-JCOnline -JumpCloudApiKey:($env:PESTER_MSP_APIKEY) -JumpCloudOrgId:($env:PESTER_ORGID) -force | Out-Null } diff --git a/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Update-JCMSPFromCSV.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Update-JCMSPFromCSV.Tests.ps1 index dfda30620..a16b45eed 100644 --- a/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Update-JCMSPFromCSV.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Utilities/CSV_Import/Update-JCMSPFromCSV.Tests.ps1 @@ -1,4 +1,4 @@ -Describe -Tag:('MSP') 'Update-JCMSPFromCSV' { +Describe -Tag:('MSP') 'Update-JCMSPFromCSV' -Skip { BeforeAll { # Validate MSP Test org is set to default: diff --git a/PowerShell/JumpCloud Module/Tests/SetupOrg.ps1 b/PowerShell/JumpCloud Module/Tests/SetupOrg.ps1 index 76fae7bf9..95c3760bf 100644 --- a/PowerShell/JumpCloud Module/Tests/SetupOrg.ps1 +++ b/PowerShell/JumpCloud Module/Tests/SetupOrg.ps1 @@ -97,7 +97,7 @@ Try { # Generate required policies foreach ( $policyName in $PesterParamsHash_Common.MultiplePolicyList ) { If (-not (Get-JCPolicy -Name $policyName)) { - New-JCPolicy -TemplateName linux_Disable_USB_Storage -Name $policyName + New-JCPolicy -TemplateName linux_Disable_USB_Storage -Name $policyName -disable_mtp $true -disable_afc $false -disable_mmc $false } } Write-Host "[Status] Finished Generating Policies: $($stopwatch.Elapsed)" @@ -211,4 +211,4 @@ $r1.value | % { $_.psobject.properties.remove('httpMetaData') } $r2.value | % { $_.psobject.properties.remove('httpMetaData') } write-Host "[Status] Exporting $($variableArray.count) variables from setupOrg" -Return $variableArray \ No newline at end of file +Return $variableArray diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 34ac39e9f..e94992fce 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -11650,6 +11650,18 @@ SystemID CommandID Status None + + Notes + + The notes of the policy to create. + + System.String + + System.String + + + None + TemplateID @@ -11690,6 +11702,18 @@ SystemID CommandID Status None + + Notes + + The notes of the policy to create. + + System.String + + System.String + + + None + TemplateName @@ -11730,6 +11754,18 @@ SystemID CommandID Status None + + Notes + + The notes of the policy to create. + + System.String + + System.String + + + None + TemplateID @@ -17461,6 +17497,18 @@ Enter a value between 1 and 2: None + + Notes + + The notes to set on the existing JumpCloud Policy. + + System.String + + System.String + + + None + PolicyID @@ -17501,6 +17549,18 @@ Enter a value between 1 and 2: None + + Notes + + The notes to set on the existing JumpCloud Policy. + + System.String + + System.String + + + None + PolicyName @@ -17541,6 +17601,18 @@ Enter a value between 1 and 2: None + + Notes + + The notes to set on the existing JumpCloud Policy. + + System.String + + System.String + + + None + PolicyID diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 469f8b884..0ba850ef2 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,17 @@ +## 2.14.3 + +Release Date: November 7, 2024 + +#### RELEASE NOTES + +``` +Removed 40 character validation for the JumpCloud API key, Add "notes" to the JCPolicy Functions +``` + +#### FEATURES: + +- Notes can be set and added when creating new policies using the Set/New-JCPolicy Functions. Notes are returned when querying Get-JCPolicy + ## 2.14.2 Release Date: October 16, 2024 @@ -9,6 +23,7 @@ Fixed a bug with `Import-JCUsersFromCSV` and `Update-JCUsersFromCSV` where the a ``` #### BUG FIXES: + - Import-JCUsersFromCSV and Update-JCUsersFromCSV are now able to update/create users even when some Attributes column are not filled in ## 2.14.1 @@ -22,6 +37,7 @@ Fixed a bug with `Set-JCUser` not having the ability to remove a user's manager ``` #### BUG FIXES: + - Set-JCUser now allows removing a user's manager by inputting a `$null` value as expected ## 2.14.0 @@ -33,6 +49,7 @@ Release Date: September 25, 2024 ``` Introduces the `Get-JCSystemKB` Function - This function will allow you to search for applied hotfixes/KBs on your Windows devices across your organization ``` + #### BUG FIXES: Fixed a bug where Get-JCPolicy would return multiple templateIDs per policy @@ -41,7 +58,6 @@ Fixed a bug where Get-JCPolicy would return multiple templateIDs per policy - Get-JCSystemKB - Returns applied hotfixes/KBs on Windows devices in your organization - ## 2.13.1 Release Date: September 09, 2024