Skip to content

Commit

Permalink
Merge pull request #579 from TheJumpCloud/JumpCloudModule_2.10.2
Browse files Browse the repository at this point in the history
JumpCloud Module 2.10.2 Release
  • Loading branch information
gweinjc authored May 30, 2024
2 parents 621f46b + f690bea commit 88c3002
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 25 deletions.
4 changes: 2 additions & 2 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: 4/02/2024
# Generated on: 5/30/2024
#

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

# Version number of this module.
ModuleVersion = '2.10.1'
ModuleVersion = '2.10.2'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions PowerShell/JumpCloud Module/Public/Systems/Get-JCSystem.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}

}
Expand Down
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
28 changes: 20 additions & 8 deletions PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

}

}

Expand Down
21 changes: 21 additions & 0 deletions PowerShell/ModuleChangelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 88c3002

Please sign in to comment.