Skip to content

Commit

Permalink
Merge pull request #611 from TheJumpCloud/CUT-4281_NullManagerJCUser
Browse files Browse the repository at this point in the history
CUT-4281: Set-JCUser Null Manager fix
  • Loading branch information
gweinjc authored Oct 1, 2024
2 parents 803985e + a1733ad commit 7195d54
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 66 deletions.
4 changes: 2 additions & 2 deletions PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The Connect-JCOnline function sets the global variable $JCAPIKEY
## SYNTAX

```
Connect-JCOnline [-force] [-JumpCloudApiKey] <String>
Connect-JCOnline [-force] [[-JumpCloudApiKey] <String>]
[[-JumpCloudOrgId] <String>] [[-JCEnvironment] <String>] [<CommonParameters>]
```

Expand Down Expand Up @@ -88,7 +88,7 @@ Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Required: False
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName)
Expand Down
2 changes: 1 addition & 1 deletion PowerShell/JumpCloud Module/Docs/JumpCloud.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: 2.14.0
Help Version: 2.14.1
Locale: en-Us
---

Expand Down
9 changes: 5 additions & 4 deletions PowerShell/JumpCloud Module/Docs/Set-JCUser.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Set-JCUser [-Username] <String> [-email <String>] [-firstname <String>] [-lastna
[-home_poBox <String>] [-home_locality <String>] [-home_region <String>] [-home_postalCode <String>]
[-home_country <String>] [-mobile_number <String>] [-home_number <String>] [-work_number <String>]
[-work_mobile_number <String>] [-work_fax_number <String>] [-external_dn <String>]
[-external_source_type <String>] [-state <String>] [-manager <String>] [-managedAppleId <String>]
[-external_source_type <String>] [-state <String>] [-manager <Object>] [-managedAppleId <String>]
[-alternateEmail <String>] [-recoveryEmail <String>]
[-EnrollmentDays <Int32>] -Attribute1_name <String> -Attribute1_value <String> -Attribute2_name <String>
-Attribute2_value <String> [<CommonParameters>]
Expand All @@ -46,7 +46,7 @@ Set-JCUser [-Username] <String> [-email <String>] [-firstname <String>] [-lastna
[-work_country <String>] [-home_streetAddress <String>] [-home_poBox <String>] [-home_locality <String>]
[-home_region <String>] [-home_postalCode <String>] [-home_country <String>] [-mobile_number <String>]
[-home_number <String>] [-work_number <String>] [-work_mobile_number <String>] [-work_fax_number <String>]
[-external_dn <String>] [-external_source_type <String>] [-state <String>] [-manager <String>]
[-external_dn <String>] [-external_source_type <String>] [-state <String>] [-manager <Object>]
[-managedAppleId <String>] [-alternateEmail <String>] [-recoveryEmail <String>]
[-EnrollmentDays <Int32>] -Attribute1_name <String>
-Attribute1_value <String> -Attribute2_name <String> -Attribute2_value <String> [<CommonParameters>]
Expand All @@ -66,7 +66,7 @@ Set-JCUser -UserID <String> [-email <String>] [-firstname <String>] [-lastname <
[-home_poBox <String>] [-home_locality <String>] [-home_region <String>] [-home_postalCode <String>]
[-home_country <String>] [-mobile_number <String>] [-home_number <String>] [-work_number <String>]
[-work_mobile_number <String>] [-work_fax_number <String>] [-external_dn <String>]
[-external_source_type <String>] [-state <String>] [-manager <String>] [-managedAppleId <String>]
[-external_source_type <String>] [-state <String>] [-manager <Object>] [-managedAppleId <String>]
[-alternateEmail <String>] [-recoveryEmail <String>]
[-EnrollmentDays <Int32>] -Attribute1_name <String> -Attribute1_value <String> -Attribute2_name <String>
-Attribute2_value <String> [<CommonParameters>]
Expand Down Expand Up @@ -671,7 +671,7 @@ Accept wildcard characters: False
The manager for the user
```yaml
Type: System.String
Type: System.Object
Parameter Sets: (All)
Aliases:

Expand Down Expand Up @@ -1065,6 +1065,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
### System.Int32
### System.String[]
### System.Management.Automation.SwitchParameter
### System.Object
## OUTPUTS
### System.Object
Expand Down
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: 9/24/2024
# Generated on: 10/1/2024
#

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

# Version number of this module.
ModuleVersion = '2.14.0'
ModuleVersion = '2.14.1'

# Supported PSEditions
# CompatiblePSEditions = @()
Expand Down
17 changes: 8 additions & 9 deletions PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
$suspended,

[Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The manager username, ID or primary email of the JumpCloud manager user; must be a valid user')]
[string]
$manager,

[Parameter(ValueFromPipelineByPropertyName = $true, HelpMessage = 'The managedAppleId for the user')]
Expand Down Expand Up @@ -322,7 +321,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline

Write-Debug 'Verifying JCAPI Key'
if ($JCAPIKEY.length -ne 40) {
Connect-JConline
Connect-JCOnline
}

$hdrs = @{
Expand Down Expand Up @@ -563,7 +562,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
# Get the manager using manager username instead of userId
if ("manager" -eq $param.Key) {
if ([System.String]::isNullOrEmpty($param.value)) {
continue
$managerValue = $null
} else {
# First check if manager returns valid user with id
# Regex match a userid
Expand Down Expand Up @@ -701,7 +700,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
$URL = "$JCUrlBasePath/api/Systemusers/$URL_ID"
Write-Debug $URL

$CurrentAttributes = Get-JCUser -UserID $URL_ID | Select-Object -ExpandProperty attributes | Select-Object value, name
$CurrentAttributes = Get-JCUser -userid $URL_ID | Select-Object -ExpandProperty attributes | Select-Object value, name
Write-Debug "There are $($CurrentAttributes.count) existing attributes"

$CustomAttributeArrayList = New-Object System.Collections.ArrayList
Expand Down Expand Up @@ -734,7 +733,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
# Get the manager using manager username instead of userId
if ("manager" -eq $param.Key) {
if ([System.String]::isNullOrEmpty($param.value)) {
continue
$managerValue = $null
} else {
# First check if manager returns valid user with id
# Regex match a userid
Expand Down Expand Up @@ -943,7 +942,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
$URL = "$JCUrlBasePath/api/Systemusers/$URL_ID"
Write-Debug $URL

$CurrentAttributes = Get-JCUser -UserID $URL_ID | Select-Object -ExpandProperty attributes | Select-Object value, name
$CurrentAttributes = Get-JCUser -userid $URL_ID | Select-Object -ExpandProperty attributes | Select-Object value, name
Write-Debug "There are $($CurrentAttributes.count) existing attributes"

foreach ($param in $PSBoundParameters.GetEnumerator()) {
Expand Down Expand Up @@ -974,7 +973,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
# Get the manager using manager username instead of userId
if ("manager" -eq $param.Key) {
if ([System.String]::isNullOrEmpty($param.value)) {
continue
$managerValue = $null
} else {
# First check if manager returns valid user with id
# Regex match a userid
Expand Down Expand Up @@ -1167,7 +1166,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
# Get the manager using manager username instead of userId
if ("manager" -eq $param.Key) {
if ([System.String]::isNullOrEmpty($param.value)) {
continue
$managerValue = $null
} else {
# First check if manager returns valid user with id
# Regex match a userid
Expand Down Expand Up @@ -1309,7 +1308,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline

$URL = "$JCUrlBasePath/api/Systemusers/$UserID"

$CurrentAttributes = Get-JCUser -UserID $UserID | Select-Object -ExpandProperty attributes | Select-Object value, name
$CurrentAttributes = Get-JCUser -userid $UserID | Select-Object -ExpandProperty attributes | Select-Object value, name
Write-Debug "There are $($CurrentAttributes.count) existing attributes"

$CustomAttributeArrayList = New-Object System.Collections.ArrayList
Expand Down
Loading

0 comments on commit 7195d54

Please sign in to comment.