Skip to content

Commit 100f516

Browse files
committed
fix serialization
1 parent aae1d8c commit 100f516

3 files changed

Lines changed: 38 additions & 8 deletions

File tree

Public/Set-LMOpsNote.ps1

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ function Set-LMOpsNote {
7676
}
7777

7878
$Scope = @()
79-
if ($ResourceIds -or $WebsiteIds -or $DeviceGroupIds) {
79+
if ($DeviceIds -or $WebsiteIds -or $DeviceGroupIds) {
8080
foreach ($deviceId in $DeviceIds) {
8181
$Scope += [PSCustomObject]@{
8282
type = "device"
@@ -128,10 +128,18 @@ function Set-LMOpsNote {
128128
$Data.tags = @()
129129
}
130130

131+
$alwaysKeepKeys = @()
132+
if ($ClearTags) {
133+
$alwaysKeepKeys += 'tags'
134+
}
135+
if ($PSBoundParameters.ContainsKey('DeviceIds') -or $PSBoundParameters.ContainsKey('WebsiteIds') -or $PSBoundParameters.ContainsKey('DeviceGroupIds')) {
136+
$alwaysKeepKeys += 'scopes'
137+
}
138+
131139
$Data = Format-LMData `
132140
-Data $Data `
133141
-UserSpecifiedKeys $MyInvocation.BoundParameters.Keys `
134-
-AlwaysKeepKeys @($(if ($ClearTags) { 'tags' } else { @() }))
142+
-AlwaysKeepKeys $alwaysKeepKeys
135143

136144
if ($PSCmdlet.ShouldProcess($Message, "Set Ops Note")) {
137145
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "PATCH" -ResourcePath $ResourcePath -Data $Data

Public/Set-LMRecipientGroup.ps1

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ The new name of the recipient group. This parameter is optional.
1818
The description of the recipient group. This parameter is optional.
1919
2020
.PARAMETER Recipients
21-
A object containing the recipients for the recipient group.
21+
An array of recipient objects for the recipient group.
2222
2323
.EXAMPLE
2424
$recipients = @(
@@ -56,7 +56,7 @@ function Set-LMRecipientGroup {
5656

5757
[String]$Description,
5858

59-
[PSCustomObject]$Recipients
59+
[Object[]]$Recipients
6060
)
6161

6262
#Check if we are logged in and have valid api creds
@@ -90,14 +90,17 @@ function Set-LMRecipientGroup {
9090
$Data = @{
9191
groupName = $NewName
9292
description = $Description
93-
recipients = $Recipients
93+
recipients = if ($PSBoundParameters.ContainsKey('Recipients')) { @($Recipients) } else { $null }
9494
}
9595

9696
#Remove empty keys so we dont overwrite them
9797
$Data = Format-LMData `
9898
-Data $Data `
9999
-UserSpecifiedKeys $MyInvocation.BoundParameters.Keys `
100-
-ConditionalKeep @{ 'name' = 'NewName' }
100+
-ConditionalKeep @{
101+
'groupName' = 'NewName'
102+
'recipients' = 'Recipients'
103+
}
101104

102105
if ($PSCmdlet.ShouldProcess($Message, "Set Recipient Group")) {
103106
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "PATCH" -ResourcePath $ResourcePath -Data $Data

Public/Set-LMRole.ps1

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,16 @@ function Set-LMRole {
461461
}
462462
}
463463

464+
$privilegeBoundParams = @(
465+
'DashboardsPermission', 'ResourcePermission', 'LMXToolBoxPermission', 'LMXPermission',
466+
'LogsPermission', 'WebsitesPermission', 'SavedMapsPermission', 'ReportsPermission', 'SettingsPermission',
467+
'CreatePrivateDashboards', 'AllowWidgetSharing', 'ConfigTabRequiresManagePermission',
468+
'AllowedToViewMapsTab', 'AllowedToManageResourceDashboards', 'ViewTraces', 'ViewSupport', 'EnableRemoteSessionForResources'
469+
)
470+
471+
$updatingPrivileges = $PSCmdlet.ParameterSetName -like '*Custom*' -or
472+
($privilegeBoundParams | Where-Object { $PSBoundParameters.ContainsKey($_) })
473+
464474
$Data = @{
465475
customHelpLabel = $CustomHelpLabel
466476
customHelpURL = $CustomHelpURL
@@ -469,14 +479,23 @@ function Set-LMRole {
469479
requireEULA = if ($RequireEULA.IsPresent) { "true" }else { "" }
470480
roleGroupId = $RoleGroupId
471481
twoFARequired = if ($TwoFARequired.IsPresent) { "true" }else { "" }
472-
privileges = if ($CustomPrivilegesObject) { $CustomPrivilegesObject }else { $Privileges }
482+
}
483+
484+
if ($updatingPrivileges) {
485+
$Data.privileges = if ($CustomPrivilegesObject) { $CustomPrivilegesObject } else { $Privileges }
486+
}
487+
488+
$alwaysKeepKeys = @()
489+
if ($updatingPrivileges) {
490+
$alwaysKeepKeys += 'privileges'
473491
}
474492

475493
#Remove empty keys so we dont overwrite them
476494
$Data = Format-LMData `
477495
-Data $Data `
478496
-UserSpecifiedKeys $MyInvocation.BoundParameters.Keys `
479-
-ConditionalKeep @{ 'name' = 'NewName' }
497+
-ConditionalKeep @{ 'name' = 'NewName' } `
498+
-AlwaysKeepKeys $alwaysKeepKeys
480499

481500
if ($PSCmdlet.ShouldProcess($Message, "Set Role")) {
482501

0 commit comments

Comments
 (0)