Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SA-3640-Get-JCassociation-Type-Bug-Fix #535

Merged
merged 5 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 31 additions & 31 deletions PowerShell/JumpCloud Module/JumpCloud.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: JumpCloud Solutions Architect Team
#
# Generated on: 10/16/2023
# Generated on: 8/1/2023
#

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

# Version number of this module.
ModuleVersion = '2.8.0'
ModuleVersion = '2.7.0'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down Expand Up @@ -51,8 +51,8 @@
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @('JumpCloud.SDK.DirectoryInsights',
'JumpCloud.SDK.V1',
RequiredModules = @('JumpCloud.SDK.DirectoryInsights',
'JumpCloud.SDK.V1',
'JumpCloud.SDK.V2')

# Assemblies that must be loaded prior to importing this module
Expand All @@ -71,33 +71,33 @@
# 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-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember',
'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Backup-JCOrganization',
'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation',
'Get-JCBackup', '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-JCSystem',
'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights',
'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-JCPolicy',
'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer',
'Remove-JCSystem', 'Remove-JCSystemGroup',
'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser',
'Remove-JCUserGroup', 'Remove-JCUserGroupMember',
'Send-JCPasswordReset', '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'
FunctionsToExport = 'Add-JCAssociation', 'Add-JCCommandTarget',
'Add-JCRadiusReplyAttribute', 'Add-JCSystemGroupMember',
'Add-JCSystemUser', 'Add-JCUserGroupMember', 'Backup-JCOrganization',
'Connect-JCOnline', 'Copy-JCAssociation', 'Get-JCAssociation',
'Get-JCBackup', '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-JCSystem',
'Get-JCSystemApp', 'Get-JCSystemGroupMember', 'Get-JCSystemInsights',
'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-JCPolicy',
'Remove-JCRadiusReplyAttribute', 'Remove-JCRadiusServer',
'Remove-JCSystem', 'Remove-JCSystemGroup',
'Remove-JCSystemGroupMember', 'Remove-JCSystemUser', 'Remove-JCUser',
'Remove-JCUserGroup', 'Remove-JCUserGroupMember',
'Send-JCPasswordReset', '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-JCU', 'Get-JCEvent', 'Get-JCEventCountsersFromCSV', 'Get-JCEvent', 'Get-JCEventCount'

# 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 = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Function Format-JCAssociation {
$AssociationProperties = $_ |
ForEach-Object { $_.PSObject.Properties.name } | Select-Object -Unique
If ($AssociationProperties) {
ForEach ($AssociationProperty In $AssociationProperties | Where-Object { $_ -notin ('id', 'type') }) {
ForEach ($AssociationProperty In $AssociationProperties | Where-Object { $_ -notin ('id', 'type', 'name') }) {
$AssociationHash.Add($AssociationProperty, $_.($AssociationProperty)) | Out-Null
}
} Else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Function Get-JCAssociation {
Get-DynamicParamAssociation -Action:($Action) -Force:($Force) -Type:($Type)
} Else {
Get-DynamicParamAssociation -Action:($Action) -Force:($Force)
$isDynamicPAram = $true
}
Return $RuntimeParameterDictionary
}
Expand All @@ -26,6 +27,17 @@ Function Get-JCAssociation {
$FunctionParameters = [ordered]@{ }
# Add input parameters from function in to hash table and filter out unnecessary parameters
$PSBoundParameters.GetEnumerator() | Where-Object { -not [System.String]::IsNullOrEmpty($_.Value) } | ForEach-Object { $FunctionParameters.Add($_.Key, $_.Value) | Out-Null }
# Check if the type is in param block or a dynamic type
if ($isDynamicPAram) {
Write-Debug "Type is not set in PARAM block"
# Set the type to the dynamic type in functionParameters
$getDynamicType = Get-JCType -Type $type
Write-Debug "Manual Type: $($getDynamicType.targets.targetsingular)"
$FunctionParameters['TargetType'] = $getDynamicType.targets.targetsingular
} else {
Write-Debug "Type is set in PARAM block: $Type"
}

# Add action
($FunctionParameters).Add('Action', $Action) | Out-Null
# Run the command
Expand Down
15 changes: 15 additions & 0 deletions PowerShell/ModuleChangelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## 2.8.1

Release Date: October 17, 2023

#### RELEASE NOTES

```
Addressed the issue with Get-JCAssociation errors when param Type is sent through dynamic parameter and duplicate key in property hash
```

### BUG FIXES:

- Fixed an issue with param targetType defaulting when dynamicParam is set
- Fixed an issue with system associated to a command where duplicate key being added

## 2.8.0

Release Date: October 16, 2023
Expand Down
Loading