Skip to content

Commit 7195d54

Browse files
authored
Merge pull request #611 from TheJumpCloud/CUT-4281_NullManagerJCUser
CUT-4281: Set-JCUser Null Manager fix
2 parents 803985e + a1733ad commit 7195d54

File tree

8 files changed

+137
-66
lines changed

8 files changed

+137
-66
lines changed

PowerShell/JumpCloud Module/Docs/Connect-JCOnline.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The Connect-JCOnline function sets the global variable $JCAPIKEY
1313
## SYNTAX
1414

1515
```
16-
Connect-JCOnline [-force] [-JumpCloudApiKey] <String>
16+
Connect-JCOnline [-force] [[-JumpCloudApiKey] <String>]
1717
[[-JumpCloudOrgId] <String>] [[-JCEnvironment] <String>] [<CommonParameters>]
1818
```
1919

@@ -88,7 +88,7 @@ Type: System.String
8888
Parameter Sets: (All)
8989
Aliases:
9090

91-
Required: True
91+
Required: False
9292
Position: 1
9393
Default value: None
9494
Accept pipeline input: True (ByPropertyName)

PowerShell/JumpCloud Module/Docs/JumpCloud.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Module Name: JumpCloud
33
Module Guid: 31c023d1-a901-48c4-90a3-082f91b31646
44
Download Help Link: https://github.com/TheJumpCloud/support/wiki
5-
Help Version: 2.14.0
5+
Help Version: 2.14.1
66
Locale: en-Us
77
---
88

PowerShell/JumpCloud Module/Docs/Set-JCUser.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Set-JCUser [-Username] <String> [-email <String>] [-firstname <String>] [-lastna
2626
[-home_poBox <String>] [-home_locality <String>] [-home_region <String>] [-home_postalCode <String>]
2727
[-home_country <String>] [-mobile_number <String>] [-home_number <String>] [-work_number <String>]
2828
[-work_mobile_number <String>] [-work_fax_number <String>] [-external_dn <String>]
29-
[-external_source_type <String>] [-state <String>] [-manager <String>] [-managedAppleId <String>]
29+
[-external_source_type <String>] [-state <String>] [-manager <Object>] [-managedAppleId <String>]
3030
[-alternateEmail <String>] [-recoveryEmail <String>]
3131
[-EnrollmentDays <Int32>] -Attribute1_name <String> -Attribute1_value <String> -Attribute2_name <String>
3232
-Attribute2_value <String> [<CommonParameters>]
@@ -46,7 +46,7 @@ Set-JCUser [-Username] <String> [-email <String>] [-firstname <String>] [-lastna
4646
[-work_country <String>] [-home_streetAddress <String>] [-home_poBox <String>] [-home_locality <String>]
4747
[-home_region <String>] [-home_postalCode <String>] [-home_country <String>] [-mobile_number <String>]
4848
[-home_number <String>] [-work_number <String>] [-work_mobile_number <String>] [-work_fax_number <String>]
49-
[-external_dn <String>] [-external_source_type <String>] [-state <String>] [-manager <String>]
49+
[-external_dn <String>] [-external_source_type <String>] [-state <String>] [-manager <Object>]
5050
[-managedAppleId <String>] [-alternateEmail <String>] [-recoveryEmail <String>]
5151
[-EnrollmentDays <Int32>] -Attribute1_name <String>
5252
-Attribute1_value <String> -Attribute2_name <String> -Attribute2_value <String> [<CommonParameters>]
@@ -66,7 +66,7 @@ Set-JCUser -UserID <String> [-email <String>] [-firstname <String>] [-lastname <
6666
[-home_poBox <String>] [-home_locality <String>] [-home_region <String>] [-home_postalCode <String>]
6767
[-home_country <String>] [-mobile_number <String>] [-home_number <String>] [-work_number <String>]
6868
[-work_mobile_number <String>] [-work_fax_number <String>] [-external_dn <String>]
69-
[-external_source_type <String>] [-state <String>] [-manager <String>] [-managedAppleId <String>]
69+
[-external_source_type <String>] [-state <String>] [-manager <Object>] [-managedAppleId <String>]
7070
[-alternateEmail <String>] [-recoveryEmail <String>]
7171
[-EnrollmentDays <Int32>] -Attribute1_name <String> -Attribute1_value <String> -Attribute2_name <String>
7272
-Attribute2_value <String> [<CommonParameters>]
@@ -671,7 +671,7 @@ Accept wildcard characters: False
671671
The manager for the user
672672
673673
```yaml
674-
Type: System.String
674+
Type: System.Object
675675
Parameter Sets: (All)
676676
Aliases:
677677

@@ -1065,6 +1065,7 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
10651065
### System.Int32
10661066
### System.String[]
10671067
### System.Management.Automation.SwitchParameter
1068+
### System.Object
10681069
## OUTPUTS
10691070
10701071
### System.Object

PowerShell/JumpCloud Module/JumpCloud.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Generated by: JumpCloud Solutions Architect Team
55
#
6-
# Generated on: 9/24/2024
6+
# Generated on: 10/1/2024
77
#
88

99
@{
@@ -12,7 +12,7 @@
1212
RootModule = 'JumpCloud.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '2.14.0'
15+
ModuleVersion = '2.14.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

PowerShell/JumpCloud Module/Public/Users/Set-JCUser.ps1

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,6 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
239239
$suspended,
240240

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

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

323322
Write-Debug 'Verifying JCAPI Key'
324323
if ($JCAPIKEY.length -ne 40) {
325-
Connect-JConline
324+
Connect-JCOnline
326325
}
327326

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

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

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

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

949948
foreach ($param in $PSBoundParameters.GetEnumerator()) {
@@ -974,7 +973,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
974973
# Get the manager using manager username instead of userId
975974
if ("manager" -eq $param.Key) {
976975
if ([System.String]::isNullOrEmpty($param.value)) {
977-
continue
976+
$managerValue = $null
978977
} else {
979978
# First check if manager returns valid user with id
980979
# Regex match a userid
@@ -1167,7 +1166,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
11671166
# Get the manager using manager username instead of userId
11681167
if ("manager" -eq $param.Key) {
11691168
if ([System.String]::isNullOrEmpty($param.value)) {
1170-
continue
1169+
$managerValue = $null
11711170
} else {
11721171
# First check if manager returns valid user with id
11731172
# Regex match a userid
@@ -1309,7 +1308,7 @@ UserID has an Alias of _id. This means you can leverage the PowerShell pipeline
13091308

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

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

13151314
$CustomAttributeArrayList = New-Object System.Collections.ArrayList

0 commit comments

Comments
 (0)