From d208cb721f278df65e0cf9555569990a81916ce0 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Wed, 15 May 2024 09:35:13 -0600 Subject: [PATCH 01/12] Remove systemToken --- .../JumpCloud Module/Public/Systems/Get-JCSystem.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 index 36e1888ac..1c1f32918 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', 'systemToken', 'templateName', 'userMetrics', 'usernameHashes', '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')] [String[]]$returnProperties ) @@ -301,7 +301,7 @@ Function Get-JCSystem () { } if ($param.key -eq 'date') { - $Timestamp = Get-Date $param.Value -format o + $Timestamp = Get-Date $param.Value -Format o continue } @@ -358,7 +358,7 @@ Function Get-JCSystem () { # Remove variables that interfere with recursive call $removeVariables = @("filterDateProperty") - $removeVariables | Foreach-Object { + $removeVariables | ForEach-Object { Remove-Variable -Name $_ | Out-Null } @@ -461,10 +461,10 @@ Function Get-JCSystem () { switch ($PSCmdlet.ParameterSetName) { SearchFilter { - return $resultsArrayList | Select-Object -ExcludeProperty associatedTagCount, sshRootEnabled + return $resultsArrayList | Select-Object -ExcludeProperty associatedTagCount, sshRootEnabled, systemToken } ByID { - return $resultsArrayList | Select-Object -ExcludeProperty associatedTagCount + return $resultsArrayList | Select-Object -ExcludeProperty associatedTagCount, systemToken } } From 1ca0039cc4d6eeaaae1f60ee3526c9cd689f16a2 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Wed, 15 May 2024 11:02:59 -0600 Subject: [PATCH 02/12] Update ModuleChangelog.md --- PowerShell/ModuleChangelog.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 6e3b6d5a2..8f8751058 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,17 @@ +## 2.10.2 + +Release Date: May 15, 2024 + +#### RELEASE NOTES + +``` +Removed the unused `systemToken` property from the Get-JCSystem function +``` + +#### FEATURES: + +Removed the `systemToken` property from the Get-JCSystem function + ## 2.10.1 Release Date: April 2, 2024 From 050fa26a9ab39ee58705fd1260e36ecf135b3c3a Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Wed, 15 May 2024 12:58:49 -0600 Subject: [PATCH 03/12] update version/date --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 6ab67f3f2..ce476b3c9 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/02/2024 +# Generated on: 5/15/2024 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. - ModuleVersion = '2.10.1' + ModuleVersion = '2.10.2' # Supported PSEditions # CompatiblePSEditions = @() From a2ce162974813368f15f6add7e5175eb43c6ec54 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Wed, 15 May 2024 12:59:00 -0600 Subject: [PATCH 04/12] add new returnproperties via swagger --- PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 | 2 +- PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 index 1c1f32918..2ffe44e56 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')] + [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')] [String[]]$returnProperties ) diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 3ed79626a..faf112246 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -73,7 +73,7 @@ Function Get-JCUser () { [String]$filterDateProperty, [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'Allows you to return select properties on JumpCloud user 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'', ''password_expiration_date'', ''account_locked'', ''activated'', ''addresses'', ''allow_public_key'', ''attributes'', ''alternateEmail'',''email'', ''enable_managed_uid'', ''enable_user_portal_multifactor'', ''externally_managed'', ''firstname'', ''lastname'', ''ldap_binding_user'', ''passwordless_sudo'', ''password_expired'', ''password_never_expires'', ''phoneNumbers'', ''samba_service_user'', ''ssh_keys'', ''sudo'', ''totp_enabled'', ''unix_guid'', ''unix_uid'', ''managedAppleId'',''manager'',''username'',''suspended'',''recoveryEmail'',''systemUsername'',''relationships'',''public_key'',''external_password_expiration_date'',''disableDeviceMaxLoginAttempts'',''password'',''state''')] - [ValidateSet('created', 'password_expiration_date', 'account_locked', 'activated', 'addresses', 'allow_public_key', 'attributes', 'alternateEmail', 'recoveryEmail', 'managedAppleId', 'manager', 'email', 'enable_managed_uid', 'enable_user_portal_multifactor', 'externally_managed', 'firstname', 'lastname', 'ldap_binding_user', 'passwordless_sudo', 'password_expired', 'password_never_expires', 'phoneNumbers', 'samba_service_user', 'ssh_keys', 'sudo', 'totp_enabled', 'unix_guid', 'unix_uid', 'username', 'middlename', 'displayname', 'jobTitle', 'employeeIdentifier', 'department', 'costCenter', 'company', 'employeeType', 'description', 'location', 'external_source_type', 'external_dn', 'suspended', 'mfa', 'recoveryEmail', 'systemUsername', 'relationships', 'public_key', 'external_password_expiration_date', 'disableDeviceMaxLoginAttempts', 'password', 'state')] + [ValidateSet('created', 'password_expiration_date', 'account_locked', 'activated', 'addresses', 'allow_public_key', 'attributes', 'alternateEmail', 'recoveryEmail', 'managedAppleId', 'manager', 'email', 'enable_managed_uid', 'enable_user_portal_multifactor', 'externally_managed', 'firstname', 'lastname', 'ldap_binding_user', 'passwordless_sudo', 'password_expired', 'password_never_expires', 'phoneNumbers', 'samba_service_user', 'ssh_keys', 'sudo', 'totp_enabled', 'unix_guid', 'unix_uid', 'username', 'middlename', 'displayname', 'jobTitle', 'employeeIdentifier', 'department', 'costCenter', 'company', 'employeeType', 'description', 'location', 'external_source_type', 'external_dn', 'suspended', 'mfa', 'recoveryEmail', 'systemUsername', 'relationships', 'public_key', 'external_password_expiration_date', 'disableDeviceMaxLoginAttempts', 'password', 'state', 'restrictedFields')] [String[]]$returnProperties, #New parameters as of 1.8 release @@ -268,7 +268,7 @@ Function Get-JCUser () { } if ($param.key -eq 'date') { - $Timestamp = Get-Date $param.Value -format o + $Timestamp = Get-Date $param.Value -Format o continue } From aaa2e3589d306b1b34999dda20c62895fc1564c4 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Tue, 21 May 2024 15:04:30 -0600 Subject: [PATCH 05/12] Fix Get-JCEvent examples --- .../Public/DirectoryInsights/Get-JCEvent.ps1 | 32 ++++++++++++++++--- .../DirectoryInsights/Get-JCEventCount.ps1 | 16 +++++++--- 2 files changed, 40 insertions(+), 8 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 index e6932d360..5baf96a59 100644 --- a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEvent.ps1 @@ -12,13 +12,37 @@ Query the API for Directory Insights events curl -X POST 'https://api.jumpcloud.com/insights/directory/v1/events' -H 'Content-Type: application/json' -H 'x-api-key: REPLACE_KEY_VALUE' --data '{\"service\": [\"all\"], \"start_time\": \"2021-07-14T23:00:00Z\", \"end_time\": \"2021-07-28T14:00:00Z\", \"sort\": \"DESC\", \"fields\": [\"timestamp\", \"event_type\", \"initiated_by\", \"success\", \"client_ip\", \"provider\", \"organization\"]}' ``` .Example -PS C:\> {{ Add code here }} +PS C:\> Get-JCEvent -Service:('all') -StartTime:((Get-date).AddDays(-30)) -{{ Add output here }} +Pull all event records from the last thirty days .Example -PS C:\> {{ Add code here }} +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddHours(-1)) -Limit:('10') -{{ Add output here }} +Get directory results from the last hour limit to the last 10 results in the time range +.Example +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Sort:("DESC") -EndTime:((Get-date).AddDays(-5)) + +Get directory results between 30 and 5 days ago, sort timestamp by descending value +.Example +PS C:\> Get-JCEvent -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -Limit:('10') -searchTermAnd:@{"event_type" = "group_create"} + +Get only group_create from the last thirty days +.Example +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermOr @{"initiated_by.username" = @("user.1", "user.2")} + +Get login events initiated by either "user.1" or "user.2" between a universal time zone range +.Example +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} + +Get all events between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com +.Example +PS C:\> Get-JCEvent -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"initiated_by.username" = "user.1"} + +Get sso events with the search term initiated_by: username with value "user.1" +.Example +PS C:\> Get-JCEvent -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "organization_update"} + +Get all events filtered by organization_update term between a date range .Inputs JumpCloud.SDK.DirectoryInsights.Models.IEventQuery diff --git a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 index 7047b17d7..f77690c23 100644 --- a/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 +++ b/PowerShell/JumpCloud Module/Public/DirectoryInsights/Get-JCEventCount.ps1 @@ -12,13 +12,21 @@ Query the API for a count of matching events curl -X POST 'https://api.jumpcloud.com/insights/directory/v1/events/count' -H 'Content-Type: application/json' -H 'x-api-key: REPLACE_KEY_VALUE' --data '{\"service\": [\"all\"], \"start_time\": \"2021-07-14T23:00:00Z\", \"end_time\": \"2021-07-28T14:00:00Z\", \"sort\": \"DESC\", \"fields\": [\"timestamp\", \"event_type\", \"initiated_by\", \"success\", \"client_ip\", \"provider\", \"organization\"]}' ``` .Example -PS C:\> {{ Add code here }} +PS C:\> Get-JCEventCount -Service:('all') -StartTime:((Get-date).AddDays(-30)) -{{ Add output here }} +Pull all event records from a specified time and count the results .Example -PS C:\> {{ Add code here }} +PS C:\> Get-JCEventCount -Service:('sso') -StartTime:('2020-04-14T00:00:00Z') -{{ Add output here }} +Pull all SSO event records from a specified time and count the results +.Example +PS C:\> Get-JCEventCount -Service:('all') -StartTime:('2020-04-14T00:00:00Z') -EndTime:('2020-04-20T23:00:00Z') -SearchTermAnd @{"event_type" = "admin_login_attempt"; "resource.email" = "admin.user@adminbizorg.com"} + +Get all events counts between a date range and match event_type = admin_login_attempt and resource.email = admin.user@adminbizorg.com +.Example +PS C:\> Get-JCEventCount -Service:('directory') -StartTime:((Get-date).AddDays(-30)) -searchTermAnd:@{"event_type" = "group_create"} + +Get only group_create event counts the last thirty days .Inputs JumpCloud.SDK.DirectoryInsights.Models.IEventQuery From ed8ca09f03bdcf5ebbaea69c8cce6c4df6563901 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Tue, 28 May 2024 09:48:10 -0600 Subject: [PATCH 06/12] add staged state check to enable mfa --- .../Public/Users/New-JCUser.ps1 | 28 +++++++++++++------ .../Public/Users/Set-JCUser.ps1 | 28 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index fad15d135..bc3958654 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -409,16 +409,28 @@ Function New-JCUser () { } if ($enable_user_portal_multifactor -eq $True) { - if ($PSBoundParameters['EnrollmentDays']) { - $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) + if ($state -eq 'STAGED') { + if ($PSBoundParameters['EnrollmentDays']) { + $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) + } else { + $exclusionUntil = (Get-Date).AddDays(7) + } + $mfa = @{ } + $mfa.Add("exclusion", $true) + $mfa.Add("exclusionDays", [string]$exclusionUntil) + $body.Add('mfa', $mfa) } else { - $exclusionUntil = (Get-Date).AddDays(7) - } + if ($PSBoundParameters['EnrollmentDays']) { + $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) + } else { + $exclusionUntil = (Get-Date).AddDays(7) + } - $mfa = @{ } - $mfa.Add("exclusion", $true) - $mfa.Add("exclusionUntil", [string]$exclusionUntil) - $body.Add('mfa', $mfa) + $mfa = @{ } + $mfa.Add("exclusion", $true) + $mfa.Add("exclusionUntil", [string]$exclusionUntil) + $body.Add('mfa', $mfa) + } } if ((($suspended -eq $true) -And ($state -eq "STAGED")) -Or (($suspended -eq $true) -And ($state -eq "ACTIVATED")) -Or (($suspended -eq $false) -And ($state -eq "SUSPENDED"))) { diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 0f015aa0e..35a907619 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -1421,16 +1421,28 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $body.add('attributes', $UpdatedAttributeArrayList) if ($enable_user_portal_multifactor -eq $True) { - if ($PSBoundParameters['EnrollmentDays']) { - $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) + if ($state -eq 'STAGED') { + if ($PSBoundParameters['EnrollmentDays']) { + $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) + } else { + $exclusionUntil = (Get-Date).AddDays(7) + } + $mfa = @{ } + $mfa.Add("exclusion", $true) + $mfa.Add("exclusionDays", [string]$exclusionUntil) + $body.Add('mfa', $mfa) } else { - $exclusionUntil = (Get-Date).AddDays(7) - } + if ($PSBoundParameters['EnrollmentDays']) { + $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) + } else { + $exclusionUntil = (Get-Date).AddDays(7) + } - $mfa = @{ } - $mfa.Add("exclusion", $true) - $mfa.Add("exclusionUntil", [string]$exclusionUntil) - $body.Add('mfa', $mfa) + $mfa = @{ } + $mfa.Add("exclusion", $true) + $mfa.Add("exclusionUntil", [string]$exclusionUntil) + $body.Add('mfa', $mfa) + } } if ((($suspended -eq $true) -And ($state -eq "ACTIVATED")) -Or (($suspended -eq $false) -And ($state -eq "SUSPENDED"))) { From 9b1782b1718fe7f4c5b68cad4b9a420ac16dd40a Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Tue, 28 May 2024 09:54:18 -0600 Subject: [PATCH 07/12] revert set-jcuser changes --- .../Public/Users/Set-JCUser.ps1 | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index 35a907619..0f015aa0e 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -1421,28 +1421,16 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $body.add('attributes', $UpdatedAttributeArrayList) if ($enable_user_portal_multifactor -eq $True) { - if ($state -eq 'STAGED') { - if ($PSBoundParameters['EnrollmentDays']) { - $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) - } else { - $exclusionUntil = (Get-Date).AddDays(7) - } - $mfa = @{ } - $mfa.Add("exclusion", $true) - $mfa.Add("exclusionDays", [string]$exclusionUntil) - $body.Add('mfa', $mfa) + if ($PSBoundParameters['EnrollmentDays']) { + $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) } else { - if ($PSBoundParameters['EnrollmentDays']) { - $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) - } else { - $exclusionUntil = (Get-Date).AddDays(7) - } - - $mfa = @{ } - $mfa.Add("exclusion", $true) - $mfa.Add("exclusionUntil", [string]$exclusionUntil) - $body.Add('mfa', $mfa) + $exclusionUntil = (Get-Date).AddDays(7) } + + $mfa = @{ } + $mfa.Add("exclusion", $true) + $mfa.Add("exclusionUntil", [string]$exclusionUntil) + $body.Add('mfa', $mfa) } if ((($suspended -eq $true) -And ($state -eq "ACTIVATED")) -Or (($suspended -eq $false) -And ($state -eq "SUSPENDED"))) { From 42f7b0055082cb9b2679533d3f265d769025bc2d Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Tue, 28 May 2024 09:58:52 -0600 Subject: [PATCH 08/12] test if user state is STAGED --- .../Tests/Public/Users/New-JCUser.Tests.ps1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.Tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.Tests.ps1 index 1ac6630cd..c9c093036 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.Tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.Tests.ps1 @@ -419,6 +419,17 @@ Describe -Tag:('JCUser') "New-JCUser MFA with enrollment periods 1.10" { $Newuser | Remove-JCUser -ByID -force } + It "Creates a new user with enable_user_portal_multifactor -eq True and a 30 days specified for EnrollmentDays and the user state is STAGED" { + + $EnrollmentDays = 30 + + $Newuser = New-RandomUser -Domain "delNewUser.$(New-RandomString -NumberOfChars 5)" | New-JCUser -enable_user_portal_multifactor $true -EnrollmentDays $EnrollmentDays -state "STAGED" + + $Newuser.mfa.exclusion | Should -Be $true + + $Newuser | Remove-JCUser -ByID -force + + } } From c12cda90fd5fd05849f9e3b66335b040001cd5f2 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Tue, 28 May 2024 15:01:03 -0600 Subject: [PATCH 09/12] update module/changelog --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 4 ++-- PowerShell/ModuleChangelog.md | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 6ab67f3f2..285200f53 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/02/2024 +# Generated on: 5/28/2024 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. - ModuleVersion = '2.10.1' + ModuleVersion = '2.10.2' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 6e3b6d5a2..62a349c7a 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,17 @@ +## 2.10.2 + +Release Date: May 28, 2024 + +#### RELEASE NOTES + +``` +Fixed a bug when creating a staged user and attempting to enable MFA +``` + +#### BUG FIXES: + +Fixed a bug when creating a staged user and attempting to enable MFA + ## 2.10.1 Release Date: April 2, 2024 From 1115baaa75ef3e63f2ff27a07ce6037f15a2687d Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Tue, 28 May 2024 16:50:00 -0600 Subject: [PATCH 10/12] remove get-date from staged check --- PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index bc3958654..ba5edac59 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -411,9 +411,9 @@ Function New-JCUser () { if ($enable_user_portal_multifactor -eq $True) { if ($state -eq 'STAGED') { if ($PSBoundParameters['EnrollmentDays']) { - $exclusionUntil = (Get-Date).AddDays($PSBoundParameters['EnrollmentDays']) + $exclusionUntil = $PSBoundParameters['EnrollmentDays'] } else { - $exclusionUntil = (Get-Date).AddDays(7) + $exclusionUntil = 7 } $mfa = @{ } $mfa.Add("exclusion", $true) From aafcc91e05089a0042a04686ef930c11582d9479 Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Wed, 29 May 2024 16:03:30 -0600 Subject: [PATCH 11/12] fix date --- 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 285200f53..581123bdf 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: 5/28/2024 +# Generated on: 5/29/2024 # @{ diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 93670fb2a..b7ff8ce8f 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,7 +1,7 @@ ## 2.10.2 -Release Date: May 28, 2024 +Release Date: May 29, 2024 #### RELEASE NOTES From f690bea95655686f58a46a14786f5eddf6e5693a Mon Sep 17 00:00:00 2001 From: Geoffrey Wein Date: Thu, 30 May 2024 10:02:20 -0600 Subject: [PATCH 12/12] fix changelog/psd1 --- PowerShell/JumpCloud Module/JumpCloud.psd1 | 2 +- PowerShell/ModuleChangelog.md | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 581123bdf..4ad0ce185 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: 5/29/2024 +# Generated on: 5/30/2024 # @{ diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index b7ff8ce8f..c41cd1c4e 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,7 +1,6 @@ ## 2.10.2 - -Release Date: May 29, 2024 +Release Date: May 30, 2024 #### RELEASE NOTES