diff --git a/.circleci/workflows.yml b/.circleci/workflows.yml index 8f97ecc25..fd4ddf8a4 100755 --- a/.circleci/workflows.yml +++ b/.circleci/workflows.yml @@ -32,7 +32,7 @@ parameters: description: 'Release Type. Accepted values [ Major, Minor, Patch ]' type: enum enum: ["Major", "Minor", "Patch"] - default: "Patch" + default: "Minor" RequiredModulesRepo: description: 'PowerShell Repository for JumpCloud SDKs' type: enum @@ -45,7 +45,7 @@ parameters: PublishToPSGallery: description: 'When `true` and when run against Master branch, this workflow will publish the latest code to PSGallery' type: boolean - default: false + default: true ManualModuleVersion: description: 'When `true` the pipeline will use the Module Version specified in JumpCloud Module JumpCloud.psd1 file' type: boolean diff --git a/PowerShell/JumpCloud Module/Docs/Get-JCUser.md b/PowerShell/JumpCloud Module/Docs/Get-JCUser.md index 39ac107b0..27b482931 100644 --- a/PowerShell/JumpCloud Module/Docs/Get-JCUser.md +++ b/PowerShell/JumpCloud Module/Docs/Get-JCUser.md @@ -24,7 +24,7 @@ Get-JCUser [[-username] ] [-firstname ] [-lastname ] [-e [-employeeIdentifier ] [-department ] [-costCenter ] [-company ] [-employeeType ] [-description ] [-location ] [-external_dn ] [-external_source_type ] [-managedAppleId ] [-manager ] [-state ] - -dateFilter -date [] + [-recoveryEmail ] -dateFilter -date [] ``` ### ByID @@ -528,6 +528,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -recoveryEmail +The recovery email of the JumpCloud user you wish to search for. + +```yaml +Type: System.String +Parameter Sets: SearchFilter +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -returnProperties 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. @@ -537,7 +552,7 @@ Valid properties that can be returned are: 'created', 'password_expiration_date' Type: System.String[] Parameter Sets: SearchFilter Aliases: -Accepted values: created, password_expiration_date, account_locked, activated, addresses, allow_public_key, attributes, alternateEmail, 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 +Accepted values: 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 Required: False Position: Named diff --git a/PowerShell/JumpCloud Module/Docs/JumpCloud.md b/PowerShell/JumpCloud Module/Docs/JumpCloud.md index 8de137ccd..3611f0ae2 100644 --- a/PowerShell/JumpCloud Module/Docs/JumpCloud.md +++ b/PowerShell/JumpCloud Module/Docs/JumpCloud.md @@ -2,7 +2,7 @@ Module Name: JumpCloud Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646 Download Help Link: https://github.com/TheJumpCloud/support/wiki -Help Version: 1.20.1 +Help Version: 1.21.0 Locale: en-US --- diff --git a/PowerShell/JumpCloud Module/Docs/New-JCUser.md b/PowerShell/JumpCloud Module/Docs/New-JCUser.md index 1650f67aa..9a5d275b7 100644 --- a/PowerShell/JumpCloud Module/Docs/New-JCUser.md +++ b/PowerShell/JumpCloud Module/Docs/New-JCUser.md @@ -25,8 +25,9 @@ New-JCUser -firstname -lastname -username -email ] [-home_locality ] [-home_region ] [-home_postalCode ] [-home_country ] [-mobile_number ] [-home_number ] [-work_number ] [-work_mobile_number ] [-work_fax_number ] [-state ] [-manager ] - [-managedAppleId ] [-alternateEmail ] [-enrollmentDays ] -Attribute1_name - -Attribute1_value -Attribute2_name -Attribute2_value [] + [-managedAppleId ] [-alternateEmail ] [-recoveryEmail ] [-enrollmentDays ] + -Attribute1_name -Attribute1_value -Attribute2_name -Attribute2_value + [] ``` ### Attributes @@ -42,9 +43,9 @@ New-JCUser -firstname -lastname -username -email ] [-home_poBox ] [-home_locality ] [-home_region ] [-home_postalCode ] [-home_country ] [-mobile_number ] [-home_number ] [-work_number ] [-work_mobile_number ] [-work_fax_number ] [-state ] - [-manager ] [-managedAppleId ] [-alternateEmail ] [-enrollmentDays ] - -Attribute1_name -Attribute1_value -Attribute2_name -Attribute2_value - [] + [-manager ] [-managedAppleId ] [-alternateEmail ] [-recoveryEmail ] + [-enrollmentDays ] -Attribute1_name -Attribute1_value -Attribute2_name + -Attribute2_value [] ``` ## DESCRIPTION @@ -658,6 +659,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -recoveryEmail +The recoveryEmail for the user + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -state A string value for putting the account into a staged, activated or suspended state diff --git a/PowerShell/JumpCloud Module/Docs/Set-JCUser.md b/PowerShell/JumpCloud Module/Docs/Set-JCUser.md index 7f4681774..ed9668284 100644 --- a/PowerShell/JumpCloud Module/Docs/Set-JCUser.md +++ b/PowerShell/JumpCloud Module/Docs/Set-JCUser.md @@ -27,8 +27,8 @@ Set-JCUser [-Username] [-email ] [-firstname ] [-lastna [-home_country ] [-mobile_number ] [-home_number ] [-work_number ] [-work_mobile_number ] [-work_fax_number ] [-external_dn ] [-external_source_type ] [-state ] [-manager ] [-managedAppleId ] - [-alternateEmail ] [-EnrollmentDays ] -Attribute1_name -Attribute1_value - -Attribute2_name -Attribute2_value [] + [-alternateEmail ] [-recoveryEmail ] [-EnrollmentDays ] -Attribute1_name + -Attribute1_value -Attribute2_name -Attribute2_value [] ``` ### RemoveAttribute @@ -46,8 +46,8 @@ Set-JCUser [-Username] [-email ] [-firstname ] [-lastna [-home_postalCode ] [-home_country ] [-mobile_number ] [-home_number ] [-work_number ] [-work_mobile_number ] [-work_fax_number ] [-external_dn ] [-external_source_type ] [-state ] [-manager ] [-managedAppleId ] - [-alternateEmail ] [-EnrollmentDays ] -Attribute1_name -Attribute1_value - -Attribute2_name -Attribute2_value [] + [-alternateEmail ] [-recoveryEmail ] [-EnrollmentDays ] -Attribute1_name + -Attribute1_value -Attribute2_name -Attribute2_value [] ``` ### ByID @@ -65,8 +65,8 @@ Set-JCUser -UserID [-email ] [-firstname ] [-lastname < [-home_country ] [-mobile_number ] [-home_number ] [-work_number ] [-work_mobile_number ] [-work_fax_number ] [-external_dn ] [-external_source_type ] [-state ] [-manager ] [-managedAppleId ] - [-alternateEmail ] [-EnrollmentDays ] -Attribute1_name -Attribute1_value - -Attribute2_name -Attribute2_value [] + [-alternateEmail ] [-recoveryEmail ] [-EnrollmentDays ] -Attribute1_name + -Attribute1_value -Attribute2_name -Attribute2_value [] ``` ## DESCRIPTION @@ -774,6 +774,21 @@ Accept pipeline input: True (ByPropertyName) Accept wildcard characters: False ``` +### -recoveryEmail +The recoveryEmail for the user + +```yaml +Type: System.String +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: True (ByPropertyName) +Accept wildcard characters: False +``` + ### -RemoveAttribute The name of the existing Custom Attributes you wish to remove. See an EXAMPLE for working with the -RemoveAttribute Parameter in EXAMPLE 5 diff --git a/PowerShell/JumpCloud Module/JumpCloud.psd1 b/PowerShell/JumpCloud Module/JumpCloud.psd1 index bd319b64d..358d701d4 100755 --- 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/28/2022 +# Generated on: 5/10/2022 # @{ @@ -12,7 +12,7 @@ RootModule = 'JumpCloud.psm1' # Version number of this module. -ModuleVersion = '1.20.1' +ModuleVersion = '1.21.0' # Supported PSEditions # CompatiblePSEditions = @() diff --git a/PowerShell/JumpCloud Module/Public/Authentication/Update-JCModule.ps1 b/PowerShell/JumpCloud Module/Public/Authentication/Update-JCModule.ps1 index 748541c41..5ce749f1a 100644 --- a/PowerShell/JumpCloud Module/Public/Authentication/Update-JCModule.ps1 +++ b/PowerShell/JumpCloud Module/Public/Authentication/Update-JCModule.ps1 @@ -44,7 +44,7 @@ Function Update-JCModule $SDKsToUninstall = @() $SDKsToUpdate = @() $SDKsUpToDate = @() - $SDKsInstalledSummary = @{} + $SDKsInstalledSummary = @() $SDKUpdateTable = @() $SDKResultsSummary = @() $SDKUninstallSummary = @() @@ -147,7 +147,7 @@ Function Update-JCModule { Do { - Write-Host ('Enter ''Y'' to update the SDK modules or enter ''N'' to cancel:') + Write-Host ('Enter ''Y'' to update the SDK modules or enter ''N'' to cancel:') -NoNewline Write-Host (' ') -NoNewline $UserInput = Read-Host } @@ -163,84 +163,96 @@ Function Update-JCModule } Else { - # For each SDK in update list - foreach ($SDK in $ComparedSDKsToUpdate) + # For each SDK in update list where we need to update: + foreach ($SDK in $SDKUpdateTable | Where-Object { $_."Update Action" -eq 'Update' }) { try { - Update-Module -Name $SDK.Name -Force - $SDKsInstalledSummary.Add($SDK.Name, 'Success') + Write-Debug -Message "Running Command: Install-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Latest Version") -Force" + Install-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Latest Version") -Force + $SDKsInstalledSummary += [PSCustomObject]@{ + 'SDK Name' = $($SDK."SDK Name") + 'Target Version' = $($SDK."Latest Version") + 'Install Success' = $true + } } catch { - $SDKsInstalledSummary.Add($SDK.Name, 'Failure') - Write-Warning -Message "$($SDK.Name) Could not be updated automatically; run the following command to install manually:" - Write-Warning -Message "Install-Module -Name $($SDK.Name)" + $SDKsInstalledSummary += [PSCustomObject]@{ + 'SDK Name' = $($SDK."SDK Name") + 'Target Version' = $($SDK."Latest Version") + 'Install Success' = $false + } + Write-Warning -Message "$($SDK."SDK Name") Could not be updated automatically; run the following command to install manually:" + Write-Warning -Message "Install-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Latest Version") -Force" } # Get and remove the current module - Get-Module -Name:($SDK.Name) -ListAvailable -All | Remove-Module -Force + Get-Module -Name:($SDK."SDK Name") -ListAvailable -All | Remove-Module -Force try { - Import-Module $SDK.Name -Scope:('Global') -Force + Write-Debug -Message "Running Command: Import-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Latest Version") -Force" + Import-Module $SDK."SDK Name" -RequiredVersion $($SDK."Latest Version") -Scope:('Global') -Force $SDKResultsSummary += [PSCustomObject]@{ - 'SDK Name' = $($SDK.Name) + 'SDK Name' = $($SDK."SDK Name") 'Imported' = $true } } catch { + Write-Debug -Message "Error: Import-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Latest Version") -Force" $SDKResultsSummary += [PSCustomObject]@{ - 'SDK Name' = $($SDK.Name) + 'SDK Name' = $($SDK."SDK Name") 'Imported' = $false } } - If (Get-InstalledModule -Name $($SDK.Name) -RequiredVersion $($SDK.Version)){ + If (Get-InstalledModule -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Installed Version")){ Try { - Uninstall-Module -Name $($SDK.Name) -RequiredVersion $($SDK.Version) + Write-Debug -Message "Running Command: Uninstall-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Installed Version") -Force" + Uninstall-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Installed Version") -Force $SDKUninstallSummary += [PSCustomObject]@{ - 'SDK Name' = $($SDK.Name) - 'Uninstalled Version' = $($SDK.Version) + 'SDK Name' = $($SDK."SDK Name") + 'Uninstalled Version' = $($SDK."Installed Version") 'Uninstalled' = $true } } Catch{ - Write-Warning -Message "Could not uninstall $($SDK.Name) $($SDK.Version)" - $SDKUninstallSummary += [PSCustomObject]@{ - 'SDK Name' = $($SDK.Name) - 'Uninstalled Version' = $($SDK.Version) - 'Uninstalled' = $false - } + Write-Warning -Message "Could not uninstall $($SDK."SDK Name") $($SDK."Installed Version")" + $SDKUninstallSummary += [PSCustomObject]@{ + 'SDK Name' = $($SDK."SDK Name") + 'Uninstalled Version' = $($SDK."Installed Version") + 'Uninstalled' = $false + } } } } - } - } - # For each SDK in uninstall list - If (!($SkipUninstallOld)) - { - if ($PSBoundParameters.Debug -eq $true -And $SDKsToUninstall.Count -ge 1) { - Write-Debug "The following out-of-date SDK Module(s) will be uninstalled" - $SDKUpdateTable | Where-Object { $_.'Update Action' -eq 'uninstall' } | Format-Table | Out-Host - } - foreach ($SDK in $SDKsToUninstall) - { - # Write-Host ('Uninstalling ' + $SDK.Name + ' module version: ' + $SDK.Version) - try + # For each SDK in uninstall list + If (!($SkipUninstallOld)) { - Uninstall-Module -Name $SDK.Name -RequiredVersion $SDK.Version -Force - $SDKUninstallSummary += [PSCustomObject]@{ - 'SDK Name' = $($SDK.Name) - 'Uninstalled Version' = $($SDK.Version) - 'Uninstalled' = $true + if ($PSBoundParameters.Debug -eq $true -And $SDKsToUninstall.Count -ge 1) { + Write-Debug "The following out-of-date SDK Module(s) will be uninstalled" + $SDKUpdateTable | Where-Object { $_.'Update Action' -eq 'uninstall' } | Format-Table | Out-Host } - } - catch - { - Write-Warning -Message "Could not uninstall $($SDK.Name) $($SDK.Version)" - $SDKUninstallSummary += [PSCustomObject]@{ - 'SDK Name' = $($SDK.Name) - 'Uninstalled Version' = $($SDK.Version) - 'Uninstalled' = $false + foreach ($SDK in $SDKUpdateTable | Where-Object { $_."Update Action" -eq 'Uninstall' }) + { + If (Get-InstalledModule -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Installed Version")){ + Try { + Write-Debug -Message "Running Command: Uninstall-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Installed Version") -Force" + Uninstall-Module -Name $($SDK."SDK Name") -RequiredVersion $($SDK."Installed Version") -Force + $SDKUninstallSummary += [PSCustomObject]@{ + 'SDK Name' = $($SDK."SDK Name") + 'Uninstalled Version' = $($SDK."Installed Version") + 'Uninstalled' = $true + } + } + Catch{ + Write-Warning -Message "Could not uninstall $($SDK."SDK Name") $($SDK."Installed Version")" + $SDKUninstallSummary += [PSCustomObject]@{ + 'SDK Name' = $($SDK."SDK Name") + 'Uninstalled Version' = $($SDK."Installed Version") + 'Uninstalled' = $false + } + } + } } } } @@ -361,8 +373,16 @@ Function Update-JCModule { if ($SDKUninstallSummary) { - if ($PSBoundParameters.Debug -eq $true) { - Write-Debug "The following modules were sucessfully uninstalled:" + if ($false -in $SDKUninstallSummary.Uninstalled){ + if ($PSBoundParameters.Debug -eq $true) { + Write-Warning "One or more of the previous SDK modules could not be uninstalled in this session" + Write-Warning "Please restart this powershell session" + Write-Debug "The following modules were unabled to be uninstalled:" + $SDKUninstallSummary | Format-Table | Out-Host + } + } + else{ + Write-Debug "The following modules were uninstalled:" $SDKUninstallSummary | Format-Table | Out-Host } } @@ -370,16 +390,16 @@ Function Update-JCModule { If ($false -in $SDKResultsSummary.Imported) { - Write-Warning "One or more of the SDK modules could not be imported to this session" - Write-Warning "Please restart this powershell session to use the new SDK module " + Write-Warning "One or more of the updated SDK modules could not be imported to this session" + Write-Warning "Please restart this powershell session to use the new SDK module(s)" if ($PSBoundParameters.Debug -eq $true) { - $SDKResultsSummary | Format-Table | Out-Host + $SDKResultsSummary | Format-Table | Out-Host } } else { if ($PSBoundParameters.Debug -eq $true) { Write-Debug "The following modules were sucessfully updated:" - $SDKResultsSummary | Format-Table | Out-Host + $SDKResultsSummary | Format-Table | Out-Host } } } diff --git a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 index 27f80c14d..402b8155e 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Get-JCUser.ps1 @@ -73,8 +73,8 @@ Function Get-JCUser () [ValidateSet('created', 'password_expiration_date')] [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''')] - [ValidateSet('created', 'password_expiration_date', 'account_locked', 'activated', 'addresses', 'allow_public_key', 'attributes', 'alternateEmail', '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')] + [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''')] + [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')] [String[]]$returnProperties, #New parameters as of 1.8 release @@ -121,7 +121,10 @@ Function Get-JCUser () [String]$manager, [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'A search filter to return users that are in an ACTIVATED, STAGED or SUSPENDED state')] - [String]$state + [String]$state, + + [Parameter(ValueFromPipelineByPropertyName, ParameterSetName = 'SearchFilter', HelpMessage = 'The recovery email of the JumpCloud user you wish to search for.')] + [String]$recoveryEmail ) DynamicParam @@ -284,6 +287,12 @@ Function Get-JCUser () continue } + if ($param.key -eq 'recoveryEmail') + { + $recoveryEmail = $param.value + continue + } + if ($param.key -eq 'date') { $Timestamp = Get-Date $param.Value -format o @@ -314,7 +323,7 @@ Function Get-JCUser () $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue){ $managerSearch = @{ filter = @{ @@ -381,6 +390,10 @@ Function Get-JCUser () { (($Search.filter).GetEnumerator()).add($DateProperty, @{$DateQuery = $Timestamp }) } + if ($recoveryEmail) + { + (($Search.filter).GetEnumerator()).add('recoveryEmail.address', $recoveryEmail ) + } $SearchJSON = $Search | ConvertTo-Json -Compress -Depth 4 diff --git a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 index a38f1a4f7..95b5af8a4 100755 --- a/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/New-JCUser.ps1 @@ -157,7 +157,10 @@ Function New-JCUser () [string]$managedAppleId, [Parameter(ValueFromPipelineByPropertyName = $True, HelpMessage = 'The alternateEmail for the user')] - [string]$alternateEmail + [string]$alternateEmail, + + [Parameter(ValueFromPipelineByPropertyName = $True, HelpMessage = 'The recoveryEmail for the user')] + [string]$recoveryEmail ) DynamicParam @@ -368,6 +371,15 @@ Function New-JCUser () continue } } + # Convert recoveryEmail from string to an object + if ($param.Key -eq 'recoveryEmail') + { + $recoveryEmailAddress = @{ + 'address' = $recoveryEmail + } + $body.Add($param.Key, $recoveryEmailAddress) + continue + } $body.add($param.Key, $param.Value) diff --git a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 index dd7dab403..7cea49152 100644 --- a/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 +++ b/PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1 @@ -249,7 +249,10 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline [Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The alternateEmail for the user')] [string] - $alternateEmail + $alternateEmail, + + [Parameter(ValueFromPipelineByPropertyName = $True, HelpMessage = 'The recoveryEmail for the user')] + [string]$recoveryEmail ) @@ -374,6 +377,14 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $URL_ID = $UserID } + # Convert recoveryEmail to an object + if ($recoveryEmail) + { + $recoveryEmailAddress = @{ + 'address' = $recoveryEmail + } + $PSBoundParameters['recoveryEmail'] = $recoveryEmailAddress + } } @@ -667,12 +678,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $body['state'] = 'SUSPENDED' } else { - switch ($state) + switch ($state) { - SUSPENDED { - $body['suspended'] = $true + SUSPENDED { + $body['suspended'] = $true } - ACTIVATED { + ACTIVATED { $body['suspended'] = $false } } @@ -745,7 +756,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $managerResults = Search-JcSdkUser -Body:($managerSearch) # Set managerValue; this is a validated user id $managerValue = $managerResults.id - # if no value was returned, then assume the case this is actuallty a username and search + # if no value was returned, then assume the case this is actually a username and search if (!$managerValue) { $managerSearch = @{ @@ -891,12 +902,12 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline $body['state'] = 'SUSPENDED' } else { - switch ($state) + switch ($state) { - SUSPENDED { - $body['suspended'] = $true + SUSPENDED { + $body['suspended'] = $true } - ACTIVATED { + ACTIVATED { $body['suspended'] = $false } } diff --git a/PowerShell/JumpCloud Module/Tests/DefineEnvironment.ps1 b/PowerShell/JumpCloud Module/Tests/DefineEnvironment.ps1 index 00d57e861..7e992d469 100644 --- a/PowerShell/JumpCloud Module/Tests/DefineEnvironment.ps1 +++ b/PowerShell/JumpCloud Module/Tests/DefineEnvironment.ps1 @@ -123,6 +123,7 @@ $PesterParamsHash_Definitions = @{ mobile_number = 'mobile_number_1' NumberOfCustomAttributes = 1 password_never_expires = $true + recoveryEmail = "$($RandomString1)re@DeleteMe.com" username = "pester.tester1_$($RandomString1)" work_city = 'work_city_1' work_country = 'work_country_1' @@ -163,6 +164,7 @@ $PesterParamsHash_Definitions = @{ mobile_number = 'mobile_number_2' NumberOfCustomAttributes = 1 password_never_expires = $true + recoveryEmail = "$($RandomString2)re@DeleteMe.com" username = "pester.tester2_$($RandomString2)" work_city = 'work_city_2' work_country = 'work_country_2' diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 index 8e728dde0..dc24b044e 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Get-JCUser.tests.ps1 @@ -59,13 +59,19 @@ Describe -Tag:('JCUser') 'Get-JCUser 1.1' { Remove-JCUser -UserID $NewUser._id -force } It "Searches a JumpCloud user by alternateEmail" -Skip { - # TODO: Implement in SA-2444 $alternateEmail = "deleteme@$(New-RandomString -NumberOfChars 8).com" $NewUser = New-RandomUser -Domain DeleteMe | New-JCUser -alternateEmail $alternateEmail $NewUser = Get-JCUser -alternateEmail $alternateEmail $NewUser.alternateEmail | Should -Be $alternateEmail Remove-JCUser -UserID $NewUser._id -force } + It "Searches a JumpCloud user by recoveryEmail" { + $recoveryEmail = "deleteme@$(New-RandomString -NumberOfChars 8).com" + $NewUser = New-RandomUser -Domain DeleteMe | New-JCUser -recoveryEmail $recoveryEmail + $NewUser = Get-JCUser -recoveryEmail $recoveryEmail + $NewUser.recoveryEmail.address | Should -Be $recoveryEmail + Remove-JCUser -UserID $NewUser._id -force + } It "Searches a JumpCloud user by managedAppleID" { $managedAppleID = "deleteme@$(New-RandomString -NumberOfChars 8).com" $NewUser = New-RandomUser -Domain DeleteMe | New-JCUser -managedAppleID $managedAppleID @@ -261,7 +267,7 @@ Describe -Tag:('JCUser') "Get-JCUser 1.4" { } It "Searches for a JumpCloud user using username and returns all properties" { - $PesterUser = Get-JCUser -username $PesterParams_User1.Username -returnProperties 'created', 'account_locked', 'activated', 'addresses', 'allow_public_key', 'attributes', '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', 'suspended', 'totp_enabled', 'unix_guid', 'unix_uid', 'username', 'alternateEmail', 'managedAppleId' + $PesterUser = Get-JCUser -username $PesterParams_User1.Username -returnProperties 'created', 'account_locked', 'activated', 'addresses', 'allow_public_key', 'attributes', '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', 'suspended', 'totp_enabled', 'unix_guid', 'unix_uid', 'username', 'alternateEmail', 'managedAppleId', 'recoveryEmail' $PesterUser.account_locked | Should -Not -Be $null $PesterUser.activated | Should -Not -Be $null $PesterUser.addresses | Should -Not -Be $null @@ -270,6 +276,7 @@ Describe -Tag:('JCUser') "Get-JCUser 1.4" { $PesterUser.attributes | Should -Not -Be $null $PesterUser.created | Should -Not -Be $null $PesterUser.email | Should -Not -Be $null + $PesterUser.recoveryEmail | Should -Not -Be $null $PesterUser.enable_managed_uid | Should -Not -Be $null $PesterUser.enable_user_portal_multifactor | Should -Not -Be $null $PesterUser.externally_managed | Should -Not -Be $null @@ -335,7 +342,6 @@ Describe -Tag:('JCUser') "Get-JCUser with new attributes 1.8.0" { $Search.location | Should -Be $PesterParams_User1.location } It "Searches for a user by alternateEmail" -Skip { - #TODO: Implement in SA-2444 $Search = Get-JCUser -alternateEmail $PesterParams_User1.alternateEmail -returnProperties alternateEmail $Search.alternateEmail | Should -Be $PesterParams_User1.alternateEmail } @@ -343,6 +349,10 @@ Describe -Tag:('JCUser') "Get-JCUser with new attributes 1.8.0" { $Search = Get-JCUser -managedAppleId $PesterParams_User1.managedAppleID -returnProperties managedAppleId $Search.managedAppleID | Should -Be $PesterParams_User1.managedAppleID } + It "Searches for a user by recoveryEmail" { + $Search = Get-JCUser -recoveryEmail $PesterParams_User1.recoveryEmail.address -returnProperties recoveryEmail + $Search.recoveryEmail.address | Should -Be $PesterParams_User1.recoveryEmail.address + } } @@ -385,5 +395,4 @@ Describe -Tag:('JCUser') "Get-JCUser 1.12" { $SearchUser._id | Should -Be $Newuser._id } - -} +} \ No newline at end of file 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 a4c471a19..eec086b62 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/New-JCUser.tests.ps1 @@ -109,6 +109,12 @@ Describe -Tag:('JCUser') 'New-JCUser 1.0' { $NewUser.alternateEmail | Should -Be $alternateEmail Remove-JCUser -UserID $NewUser._id -ByID -Force } + It "Creates a new User sets recoveryEmail" { + $recoveryEmail = "$((New-RandomString -NumberOfChars 6))re@DeleteMe.com" + $NewUser = New-RandomUser -domain pleasedelete"PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser -recoveryEmail $recoveryEmail + $NewUser.recoveryEmail.address | Should -Be $recoveryEmail + Remove-JCUser -UserID $NewUser._id -ByID -Force + } It "Creates a new User sets managedAppleID" { $managedAppleID = "$((New-RandomString -NumberOfChars 6))maid@DeleteMe.com" $NewUser = New-RandomUser -domain pleasedelete"PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser -managedAppleID $managedAppleID @@ -417,4 +423,4 @@ Describe -Tag:('JCUser') "New-JCUser with suspend param 1.15" { Remove-JCUser -UserID $NewUser._id -ByID -Force } -} +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 b/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 index a3e24b54a..8c1b653a4 100755 --- a/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 +++ b/PowerShell/JumpCloud Module/Tests/Public/Users/Set-JCUser.tests.ps1 @@ -46,6 +46,12 @@ Describe -Tag:('JCUser') 'Set-JCUser 1.0' { $Newalternateemail.alternateEmail | Should -Be $RandomEmail Remove-JCUser -UserID $NewUser._id -force } + It "Updates the recoveryEmail using -Username" { + $NewUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser + $Newrecoveryemail = Set-JCUser -Username $NewUser.Username -recoveryEmail $RandomEmail + $Newrecoveryemail.recoveryEmail.address | Should -Be $RandomEmail + Remove-JCUser -UserID $NewUser._id -force + } It "Updates the alternateEmail using -ByID and -UserID" { $NewUser = New-RandomUser "PesterTest$(Get-Date -Format MM-dd-yyyy)" | New-JCUser $Newalternateemail = Set-JCUser -ByID -UserID $NewUser._id -alternateEmail $RandomEmail @@ -1514,4 +1520,4 @@ Describe -Tag:('JCUser') 'Set-JCUser with State param via UserID' { { Set-JCUser -UserID $NewUser.id -state "ACTIVATED" -suspended $true | Should -Throw } Remove-JCUser -UserID $NewUser._id -ByID -Force } -} +} \ No newline at end of file diff --git a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml index 0a9604b05..ad3cb65cb 100644 --- a/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml +++ b/PowerShell/JumpCloud Module/en-Us/JumpCloud-help.xml @@ -7547,6 +7547,18 @@ PS C:\> $BackupJcOrganizationResults.User None + + recoveryEmail + + The recovery email of the JumpCloud user you wish to search for. + + System.String + + System.String + + + None + returnProperties @@ -7561,6 +7573,7 @@ PS C:\> $BackupJcOrganizationResults.User allow_public_key attributes alternateEmail + recoveryEmail managedAppleId manager email @@ -7595,6 +7608,7 @@ PS C:\> $BackupJcOrganizationResults.User external_dn suspended mfa + recoveryEmail System.String[] @@ -8081,6 +8095,18 @@ PS C:\> $BackupJcOrganizationResults.User None + + recoveryEmail + + The recovery email of the JumpCloud user you wish to search for. + + System.String + + System.String + + + None + returnProperties @@ -10077,6 +10103,18 @@ SystemID CommandID Status None + + recoveryEmail + + The recoveryEmail for the user + + System.String + + System.String + + + None + state @@ -10697,6 +10735,18 @@ SystemID CommandID Status None + + recoveryEmail + + The recoveryEmail for the user + + System.String + + System.String + + + None + state @@ -15495,6 +15545,18 @@ Enter a value between 1 and 2: None + + recoveryEmail + + The recoveryEmail for the user + + System.String + + System.String + + + None + state @@ -16178,6 +16240,18 @@ Enter a value between 1 and 2: None + + recoveryEmail + + The recoveryEmail for the user + + System.String + + System.String + + + None + RemoveAttribute @@ -16857,6 +16931,18 @@ Enter a value between 1 and 2: None + + recoveryEmail + + The recoveryEmail for the user + + System.String + + System.String + + + None + state @@ -17524,6 +17610,18 @@ Enter a value between 1 and 2: None + + recoveryEmail + + The recoveryEmail for the user + + System.String + + System.String + + + None + RemoveAttribute diff --git a/PowerShell/ModuleBanner.md b/PowerShell/ModuleBanner.md index 119d01f6f..b169fabdc 100755 --- a/PowerShell/ModuleBanner.md +++ b/PowerShell/ModuleBanner.md @@ -1,18 +1,17 @@ #### Latest Version ``` -1.20.1 +1.21.0 ``` #### Banner Current ``` -* Get-JcUser, Set-JcUser and New-JcUser will soon be deprecating the -suspended parameter. Please use the -state paramater as a replacement. +New parameter -recoveryemail for Set, Get, New-JCUser ``` #### Banner Old ``` -* New Function, Backup-JCOrganization -* https://github.com/TheJumpCloud/support/tree/master/PowerShell/JumpCloud%20Module/Docs/Backup-JCOrganization.md +Get-JcUser, Set-JcUser and New-JcUser will soon be deprecating the -suspended parameter. Please use the -state paramater as a replacement. ``` diff --git a/PowerShell/ModuleChangelog.md b/PowerShell/ModuleChangelog.md index e37621e73..a10b1de35 100644 --- a/PowerShell/ModuleChangelog.md +++ b/PowerShell/ModuleChangelog.md @@ -1,3 +1,25 @@ +## 1.21.0 + +Release Date: May 11, 2022 + +#### RELEASE NOTES + +``` +This release includes an update to Update-JCModule intended to help updating future fersions of the PowerShell SDK + +``` +#### IMPROVEMENTS: + +* Update-JCModule specifically targets which version of the new SDK to install and uninstall. + +#### FEATURES: + +* This release adds the -recoveryemail parameter to Set, Get, New-JCUser + +#### BUG FIXES: + +N/A + ## 1.20.1 Release Date: April 28, 2022