Skip to content

Commit ada4e94

Browse files
Merge pull request #16 from logicmonitor/develop
Staging 6.5 release
2 parents 12a1203 + 3be53e4 commit ada4e94

File tree

5 files changed

+143
-19
lines changed

5 files changed

+143
-19
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<#
2+
.SYNOPSIS
3+
Removes a property from a LogicMonitor device group.
4+
5+
.DESCRIPTION
6+
The Remove-LMDeviceGroupProperty function removes a specified property from a LogicMonitor device group. It can remove the property either by providing the device group ID or the device group name.
7+
8+
.PARAMETER Id
9+
The ID of the device group from which the property should be removed. This parameter is mandatory when using the 'Id' parameter set.
10+
11+
.PARAMETER Name
12+
The name of the device group from which the property should be removed. This parameter is mandatory when using the 'Name' parameter set.
13+
14+
.PARAMETER PropertyName
15+
The name of the property to be removed. This parameter is mandatory.
16+
17+
.EXAMPLE
18+
Remove-LMDeviceGroupProperty -Id 1234 -PropertyName "Property1"
19+
Removes the property named "Property1" from the device with ID 1234.
20+
21+
.EXAMPLE
22+
Remove-LMDeviceGroupProperty -Name "Device1" -PropertyName "Property2"
23+
Removes the property named "Property2" from the device with the name "Device1".
24+
25+
.INPUTS
26+
None.
27+
28+
.OUTPUTS
29+
System.Management.Automation.PSCustomObject. The output object contains the following properties:
30+
- Id: The ID of the device group from which the property was removed.
31+
- Message: A message indicating the success of the operation.
32+
33+
.NOTES
34+
- This function requires a valid LogicMonitor API authentication. Make sure you are logged in before running any commands.
35+
- Use the Connect-LMAccount function to log in before using this function.
36+
#>
37+
Function Remove-LMDeviceGroupProperty {
38+
39+
[CmdletBinding(DefaultParameterSetName = 'Id', SupportsShouldProcess, ConfirmImpact = 'High')]
40+
Param (
41+
[Parameter(Mandatory, ParameterSetName = 'Id')]
42+
[Int]$Id,
43+
44+
[Parameter(Mandatory, ParameterSetName = 'Name')]
45+
[String]$Name,
46+
47+
[Parameter(Mandatory)]
48+
[String]$PropertyName
49+
50+
)
51+
Begin {}
52+
Process {
53+
#Check if we are logged in and have valid api creds
54+
If ($Script:LMAuth.Valid) {
55+
56+
#Lookup Id if supplying username
57+
If ($Name) {
58+
$LookupResult = (Get-LMDeviceGroup -Name $Name).Id
59+
If (Test-LookupResult -Result $LookupResult -LookupString $Name) {
60+
return
61+
}
62+
$Id = $LookupResult
63+
}
64+
65+
#Build header and uri
66+
$ResourcePath = "/device/groups/$Id/properties/$PropertyName"
67+
68+
If ($Name) {
69+
$Message = "Id: $Id | Name: $Name | Property: $PropertyName"
70+
}
71+
Else {
72+
$Message = "Id: $Id | Property: $PropertyName"
73+
}
74+
75+
Try {
76+
If ($PSCmdlet.ShouldProcess($Message, "Remove Device Group Property")) {
77+
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "DELETE" -ResourcePath $ResourcePath
78+
$Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath
79+
80+
Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation
81+
82+
#Issue request
83+
$Response = Invoke-RestMethod -Uri $Uri -Method "DELETE" -Headers $Headers[0] -WebSession $Headers[1]
84+
85+
$Result = [PSCustomObject]@{
86+
Id = $Id
87+
Message = "Successfully removed ($Message)"
88+
}
89+
90+
Return $Result
91+
}
92+
}
93+
Catch [Exception] {
94+
$Proceed = Resolve-LMException -LMException $PSItem
95+
If (!$Proceed) {
96+
Return
97+
}
98+
}
99+
}
100+
Else {
101+
Write-Error "Please ensure you are logged in before running any commands, use Connect-LMAccount to login and try again."
102+
}
103+
}
104+
End {}
105+
}

Public/Set-LMCollectorConfig.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ Function Set-LMCollectorConfig {
104104
$Value = $Value.toString().toLower()
105105

106106
$ConfigArray = $Config.Split([Environment]::NewLine)
107-
[int[]]$Index = [Linq.Enumerable]::Range(0, $ConfigArray.Count).Where({ Param($i) $ConfigArray[$i] -match $ConfLine })
107+
[int[]]$Index = [Linq.Enumerable]::Range(0, $ConfigArray.Count).Where({ Param($i) $ConfigArray[$i] -match "^$ConfLine" })
108108
If (($Index | Measure-Object).Count -eq 1) {
109109
Write-Information "[INFO]: Updating config parameter $ConfLine to value $Value."
110110
$ConfigArray[$Index[0]] = "$ConfLine=$Value"

Public/Set-LMDeviceDatasourceInstance.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ Specifies the description for the instance.
2020
.PARAMETER Properties
2121
Specifies a hashtable of custom properties for the instance.
2222
23+
.PARAMETER PropertiesMethod
24+
Specifies the method to use when updating the properties. Valid values are "Add", "Replace", or "Refresh".
25+
2326
.PARAMETER StopMonitoring
2427
Specifies whether to stop monitoring the instance. This parameter accepts $true or $false.
2528
@@ -70,6 +73,9 @@ Function Set-LMDeviceDatasourceInstance {
7073

7174
[Hashtable]$Properties,
7275

76+
[ValidateSet("Add", "Replace", "Refresh")] # Add will append to existing prop, Replace will update existing props if specified and add new props, refresh will replace existing props with new
77+
[String]$PropertiesMethod = "Replace",
78+
7379
[Nullable[boolean]]$StopMonitoring,
7480

7581
[Nullable[boolean]]$DisableAlerting,
@@ -162,7 +168,7 @@ Function Set-LMDeviceDatasourceInstance {
162168

163169
If ($PSCmdlet.ShouldProcess($Message, "Set Device Datasource Instance")) {
164170
$Headers = New-LMHeader -Auth $Script:LMAuth -Method "PATCH" -ResourcePath $ResourcePath -Data $Data
165-
$Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath
171+
$Uri = "https://$($Script:LMAuth.Portal).logicmonitor.com/santaba/rest" + $ResourcePath + "?opType=$($PropertiesMethod.ToLower())"
166172

167173
Resolve-LMDebugInfo -Url $Uri -Headers $Headers[0] -Command $MyInvocation -Payload $Data
168174

README.md

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -427,25 +427,18 @@ This change aims to enhance visibility within the community and to foster a more
427427

428428
We appreciate your continued support and enthusiasm for the Logic.Monitor PowerShell module. Your contributions and feedback are vital to the success of this project, and we look forward to seeing how the module evolves with your participation.
429429

430-
## 6.4.1
430+
## 6.5
431431
### Module Updates/Changes
432-
- **Write-LMHost** has been removed entirely starting in this version and replaced with native Write-Information,Warning and Error cmdlets. If you would like to suppress the output of these cmdlets you can use the *\$InformationPreference*, *\$DebugPreference* and *\$WarningPreference* variables. Additionally you can use the *-DisableConsoleLogging* switch on Connect-LMAccount to suppress Write-Information output.
433-
- New/Updated Pester tests have been added to validate the module builds and ensure functionality for the following cmdlets:
434-
- AccessGroup
435-
- AppliesToFunction
436-
- AppliesToSearch
437-
- Device
438-
- DeviceGroup
439-
- NetScanGroup
440-
- OpsNotes
441-
- ReportGroup
442-
- SDT
443-
- Users/Roles
444-
- Website
445-
- WebsiteGroup
432+
- **Set-LMDeviceDatasourceInstance**: Added `-PropertiesMethod` parameter to control property update behavior. Defaults to "Replace" to match other property-related cmdlets.
433+
- **Copy-LMDashboard**: Added `-DashboardTokens` parameter (hashtable) to override tokens when cloning dashboards.
434+
- **Copy-Report**: Now accepts a report object as a template for cloning. This enables customization of properties, resource scope, and other parameters before creating the copy.
435+
- **New-LMNetScan** and **Set-LMNetScan**: Added `-Schedule` parameter that accepts a PSCustomObject to define scan scheduling. Maintains default manual scheduling when parameter is omitted.
446436

447-
### New Cmdlets:
448-
- **New-LMAccessGroupMapping**: This cmdlet will create a new access group mapping/unmapping based on specified module and accessgroups.
437+
### New Cmdlets
438+
- **Remove-LMDeviceGroupProperty**: Enables removal of device properties at the resource group level.
439+
440+
### Bug Fixes
441+
- **Set-LMCollectorConfig**: Resolved an issue where similar configuration paths could cause unintended multiple updates.
449442

450443

451444
[Previous Release Notes](RELEASENOTES.md)

RELEASENOTES.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,24 @@
11
# Previous module release notes
2+
## 6.4.1
3+
### Module Updates/Changes
4+
- **Write-LMHost** has been removed entirely starting in this version and replaced with native Write-Information,Warning and Error cmdlets. If you would like to suppress the output of these cmdlets you can use the *\$InformationPreference*, *\$DebugPreference* and *\$WarningPreference* variables. Additionally you can use the *-DisableConsoleLogging* switch on Connect-LMAccount to suppress Write-Information output.
5+
- New/Updated Pester tests have been added to validate the module builds and ensure functionality for the following cmdlets:
6+
- AccessGroup
7+
- AppliesToFunction
8+
- AppliesToSearch
9+
- Device
10+
- DeviceGroup
11+
- NetScanGroup
12+
- OpsNotes
13+
- ReportGroup
14+
- SDT
15+
- Users/Roles
16+
- Website
17+
- WebsiteGroup
18+
19+
### New Cmdlets:
20+
- **New-LMAccessGroupMapping**: This cmdlet will create a new access group mapping/unmapping based on specified module and accessgroups.
21+
222
## 6.3
323
### New Cmdlets:
424
- **Get-LMLogSource**: This cmdlet will retrieve data for specified LogSources.

0 commit comments

Comments
 (0)