diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index 6ab67f3f2..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: 4/02/2024 +# Generated on: 5/30/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/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 diff --git a/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 b/PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1 index 36e1888ac..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', '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', 'isPolicyBound')] [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 } } 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 } diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index fad15d135..ba5edac59 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 = $PSBoundParameters['EnrollmentDays'] + } else { + $exclusionUntil = 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/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 + + } } diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index 6e3b6d5a2..c41cd1c4e 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,24 @@ +## 2.10.2 + +Release Date: May 30, 2024 + +#### RELEASE NOTES + +``` +Fixed a bug when creating a staged user and attempting to enable MFA +Removed the unused `systemToken` property from the Get-JCSystem function +``` + +#### BUG FIXES: + +Fixed a bug when creating a staged user and attempting to enable MFA + + +#### FEATURES: + +Removed the `systemToken` property from the Get-JCSystem function + + ## 2.10.1 Release Date: April 2, 2024