Skip to content

CUT-4857 bug fix for update-jcdevicefromcsv#700

Merged
kmaranionjc merged 20 commits into
masterfrom
CUT-4857-Update-JCDeviceFromCSV-exclude-bug
Sep 8, 2025
Merged

CUT-4857 bug fix for update-jcdevicefromcsv#700
kmaranionjc merged 20 commits into
masterfrom
CUT-4857-Update-JCDeviceFromCSV-exclude-bug

Conversation

@kmaranionjc
Copy link
Copy Markdown
Contributor

@kmaranionjc kmaranionjc commented Aug 22, 2025

Issues

What does this solve?

  • Fixes an issue with Select-Object -excludeProperty incompatibility with PWSH 5 that causes error when using the CSV system update.
  • Skipped configuredPolicyTemplate since there's a bug where it is returning all results instead of specifics.

Is there anything particularly tricky?

n/a

How should this be tested?

  1. Create a CSV using New-JCDeviceUpdateTemplate
  2. Update a system's property on the CSV such as Description
  3. Run Update-JCDeviceFromCSV -CSVFilePath "YOURPATH" on a PWSH 5 terminal
  4. Validate that it updates the device in JC and no error should pop up such as below:
image

@kmaranionjc kmaranionjc requested a review from a team as a code owner August 22, 2025 15:55
@kmaranionjc kmaranionjc requested review from Copilot and gweinjc and removed request for gweinjc August 22, 2025 15:55
@kmaranionjc kmaranionjc self-assigned this Aug 22, 2025
@kmaranionjc kmaranionjc added PowerShell Module Release for JumpCloud PowerShell Module patch labels Aug 22, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR addresses a bug in the Update-JCDeviceFromCSV function that affects PowerShell 5.1 compatibility when excluding properties. The fix replaces the problematic Select-Object -ExcludeProperty approach with a more explicit property selection method.

  • Updated the Update-JCDeviceFromCSV function to use explicit property filtering instead of -ExcludeProperty
  • Incremented module version from 2.18.1 to 2.18.2
  • Simplified FunctionsToExport to use wildcard export

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ModuleChangelog.md Added release notes for version 2.18.2 documenting the bug fix
Update-JCDeviceFromCSV.ps1 Replaced -ExcludeProperty with explicit property filtering for PowerShell 5.1 compatibility
JumpCloud.psd1 Updated module version and simplified function exports

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

# Tags applied to this module. These help with module discovery in online galleries.
Tags = 'JumpCloud', 'DaaS', 'Jump', 'Cloud', 'Directory'
# 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 = '*'
Copy link

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using wildcard '*' for FunctionsToExport goes against PowerShell module best practices and the existing comment on line 73 which explicitly states 'for best performance, do not use wildcards'. This change removes the explicit function list which was better for performance and module loading times.

Suggested change
FunctionsToExport = '*'
FunctionsToExport = @()

Copilot uses AI. Check for mistakes.
Comment thread PowerShell/JumpCloud Module/Docs/Get-JCSystem.md
<command:parameterValue required="false" command:variableLength="false">desktopCapable</command:parameterValue>
<command:parameterValue required="false" command:variableLength="false">sshRootEnabled</command:parameterValue>
<command:parameterValue required="false" command:variableLength="false">isPolicyBound</command:parameterValue>
<command:parameterValue required="false" command:variableLength="false">agentHasFullDiskAccess</command:parameterValue>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PrimarySystemUser fields should be removed

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', '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')]
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'', ''isPolicyBound'',''agentHasFullDiskAccess'', ''primarySystemUser.account_locked_date'', ''primarySystemUser.lastname'', ''primarySystemUser.samba_service_user'', ''primarySystemUser._id'', ''primarySystemUser.jobTitle'', ''primarySystemUser.allow_public_key'', ''primarySystemUser.organization'', ''primarySystemUser.creationSource'', ''primarySystemUser.ssh_keys'', ''primarySystemUser.totp_enabled'', ''primarySystemUser.disableDeviceMaxLoginAttempts'', ''primarySystemUser.displayname'', ''primarySystemUser.state'', ''primarySystemUser.addresses'', ''primarySystemUser.admin'', ''primarySystemUser.created'', ''primarySystemUser.manager'', ''primarySystemUser.username'', ''primarySystemUser.attributes'', ''primarySystemUser.firstname'', ''primarySystemUser.password_never_expires'', ''primarySystemUser.managedAppleId'', ''primarySystemUser.activated'', ''primarySystemUser.recoveryEmail'', ''primarySystemUser.external_password_expiration_date'', ''primarySystemUser.employeeType'', ''primarySystemUser.enable_managed_uid'', ''primarySystemUser.sudo'', ''primarySystemUser.ldap_binding_user'', ''primarySystemUser.enable_user_portal_multifactor'', ''primarySystemUser.phoneNumbers'', ''primarySystemUser.middlename'', ''primarySystemUser.externally_managed'', ''primarySystemUser.costCenter'', ''primarySystemUser.password_date'', ''primarySystemUser.description'', ''primarySystemUser.passwordless_sudo'', ''primarySystemUser.alternateEmail'', ''primarySystemUser.badLoginAttempts'', ''primarySystemUser.company'', ''primarySystemUser.password_expired'', ''primarySystemUser.relationships'', ''primarySystemUser.mfaEnrollment'', ''primarySystemUser.employeeIdentifier'', ''primarySystemUser.external_dn'', ''primarySystemUser.account_locked'', ''primarySystemUser.location'', ''primarySystemUser.email'', ''primarySystemUser.mfa'', ''primarySystemUser.unix_uid'', ''primarySystemUser.department'', ''primarySystemUser.password_expiration_date'', ''primarySystemUser.external_source_type'', ''primarySystemUser.public_key'', ''primarySystemUser.suspended'', ''primarySystemUser.restrictedFields'', ''primarySystemUser.unix_guid'', ''primarySystemUser.tags''')]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PrimarySystemUser should be removed

}
Describe -Tag:('JCSystemInsights') "Get-JCSystemInsights Tests" {
# TODO: Waiting on the API team to fix an issue with the authorized_key endpoint
Describe -Tag:('JCSystemInsights') "Get-JCSystemInsights Tests" -Skip {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to get a response from support/ product before skipping this test

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currently skipping because of API error with authorized_keys

@kmaranionjc kmaranionjc changed the title bug fix for update-jcdevicefromcsv CUT-4857 bug fix for update-jcdevicefromcsv Sep 4, 2025
jworkmanjc
jworkmanjc previously approved these changes Sep 8, 2025
}
It ('Get administrators by enableMultifactor') {
$Admins = Get-JCAdmin -enableMultifactor $false
$Admins = Get-JCAdmin -enableMultifactor $true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for switching this to true?

}
It ('Get administrators by email, enableMultifactor, totpEnrolled, roleName') {
$Admins = Get-JCAdmin -email 'solutions-architecture*' -enableMultifactor $false -totpEnrolled $true -roleName 'Administrator'
$Admins = Get-JCAdmin -email 'solutions-architecture*' -enableMultifactor $true -totpEnrolled $true -roleName 'Administrator'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question above

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jworkmanjc I think all the admins in the pester orgs now have MTP enabled so the tests might have been failing as nothing was found

Maybe @kmaranionjc can confirm

Comment thread PowerShell/JumpCloud Module/Tests/Public/Systems/Get-JCSystemInsights.Tests.ps1 Outdated
@gweinjc gweinjc self-requested a review September 8, 2025 16:45
Copy link
Copy Markdown
Contributor

@gweinjc gweinjc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything appears to be working on 5.0 now, nice job

@kmaranionjc kmaranionjc merged commit 5824809 into master Sep 8, 2025
27 of 30 checks passed
@kmaranionjc kmaranionjc deleted the CUT-4857-Update-JCDeviceFromCSV-exclude-bug branch September 8, 2025 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch PowerShell Module Release for JumpCloud PowerShell Module

Development

Successfully merging this pull request may close these issues.

4 participants