CUT-4857 bug fix for update-jcdevicefromcsv#700
Conversation
There was a problem hiding this comment.
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-JCDeviceFromCSVfunction to use explicit property filtering instead of-ExcludeProperty - Incremented module version from 2.18.1 to 2.18.2
- Simplified
FunctionsToExportto 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 = '*' |
There was a problem hiding this comment.
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.
| FunctionsToExport = '*' | |
| FunctionsToExport = @() |
| <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> |
There was a problem hiding this comment.
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''')] |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Need to get a response from support/ product before skipping this test
There was a problem hiding this comment.
currently skipping because of API error with authorized_keys
| } | ||
| It ('Get administrators by enableMultifactor') { | ||
| $Admins = Get-JCAdmin -enableMultifactor $false | ||
| $Admins = Get-JCAdmin -enableMultifactor $true |
There was a problem hiding this comment.
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' |
There was a problem hiding this comment.
@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
…nsights.Tests.ps1
gweinjc
left a comment
There was a problem hiding this comment.
Everything appears to be working on 5.0 now, nice job
Issues
What does this solve?
Select-Object -excludePropertyincompatibility with PWSH 5 that causes error when using the CSV system update.Is there anything particularly tricky?
n/a
How should this be tested?
New-JCDeviceUpdateTemplateUpdate-JCDeviceFromCSV -CSVFilePath "YOURPATH"on a PWSH 5 terminal