LogicMonitor.PowerShell
3.236.14
dotnet add package LogicMonitor.PowerShell --version 3.236.14
NuGet\Install-Package LogicMonitor.PowerShell -Version 3.236.14
<PackageReference Include="LogicMonitor.PowerShell" Version="3.236.14" />
<PackageVersion Include="LogicMonitor.PowerShell" Version="3.236.14" />
<PackageReference Include="LogicMonitor.PowerShell" />
paket add LogicMonitor.PowerShell --version 3.236.14
#r "nuget: LogicMonitor.PowerShell, 3.236.14"
#:package LogicMonitor.PowerShell@3.236.14
#addin nuget:?package=LogicMonitor.PowerShell&version=3.236.14
#tool nuget:?package=LogicMonitor.PowerShell&version=3.236.14
LogicMonitor PowerShell Module
This PowerShell module provides a wrapper around the LogicMonitor.Api .NET library, enabling you to interact with LogicMonitor's REST API using PowerShell cmdlets.
Installation
From Local Build
- Clone the repository
- Build the solution
- Import the module:
Import-Module .\LogicMonitor.PowerShell\bin\Debug\net9.0\LogicMonitor
From PowerShell Gallery (when published)
Install-Module -Name LogicMonitor
Configuration
Before using the module, you need to configure your LogicMonitor credentials:
# Connect to LogicMonitor
Connect-LogicMonitor -Account "yourcompany" -AccessId "your-access-id" -AccessKey "your-access-key"
Basic Usage Examples
Get All Resources
# Get all monitored resources
$resources = Get-LMResource
# Get resources with specific filter
$webServers = Get-LMResource -Filter @{ Name = "*web*" }
Get Alerts
# Get all active alerts
$alerts = Get-LMAlert
# Get critical alerts only
$criticalAlerts = Get-LMAlert -Level "critical"
Get Dashboards
# Get all dashboards
$dashboards = Get-LMDashboard
# Get specific dashboard by name
$dashboard = Get-LMDashboard -Name "Infrastructure Overview"
Resource Management
# Create a new resource
$newResource = New-LMResource -Name "MyServer" -DisplayName "My Server" -ResourceGroupId 1
# Update resource properties
Set-LMResourceProperty -ResourceId 123 -Name "custom.property" -Value "some value"
# Remove a resource
Remove-LMResource -ResourceId 123
Data Collection
# Get performance data
$data = Get-LMResourceData -ResourceId 123 -DataSourceName "CPU" -StartTime (Get-Date).AddHours(-1)
# Get raw data for specific instance
$rawData = Get-LMRawData -ResourceId 123 -DataSourceId 456 -InstanceId 789 -StartTime (Get-Date).AddDays(-1)
Available Cmdlets
Connection Management
Connect-LogicMonitor- Establish connection to LogicMonitor APIDisconnect-LogicMonitor- Close connection to LogicMonitor APITest-LMConnection- Test current connection status
Resource Management
Get-LMResource- Retrieve resourcesNew-LMResource- Create new resourceSet-LMResource- Update resourceRemove-LMResource- Delete resourceGet-LMResourceGroup- Retrieve resource groupsNew-LMResourceGroup- Create new resource group
Alert Management
Get-LMAlert- Retrieve alertsSet-LMAlert- Update alert (acknowledge, etc.)Get-LMAlertRule- Retrieve alert rules
Dashboard Management
Get-LMDashboard- Retrieve dashboardsGet-LMDashboardGroup- Retrieve dashboard groups
Data Collection
Get-LMResourceData- Get performance dataGet-LMRawData- Get raw metric dataGet-LMGraphData- Get graph data
User Management
Get-LMUser- Retrieve usersNew-LMUser- Create new userSet-LMUser- Update userRemove-LMUser- Delete user
Collector Management
Get-LMCollector- Retrieve collectorsGet-LMCollectorGroup- Retrieve collector groups
Error Handling
The module provides consistent error handling with meaningful error messages:
try {
$resource = Get-LMResource -Id 999999
}
catch {
Write-Error "Failed to retrieve resource: $($_.Exception.Message)"
}
Advanced Usage
Custom Filters
# Complex filtering
$filter = @{
Name = "*prod*"
Type = "Server"
Status = "Normal"
}
$resources = Get-LMResource -Filter $filter
Bulk Operations
# Process multiple resources
$resources = Get-LMResource -Filter @{ Group = "Production" }
foreach ($resource in $resources) {
Set-LMResourceProperty -ResourceId $resource.Id -Name "environment" -Value "prod"
}
Contributing
Contributions are welcome! Please see the main repository for contribution guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- LogicMonitor.Api (>= 3.236.14)
- Microsoft.Extensions.Logging (>= 10.0.5)
- Microsoft.Extensions.Logging.Console (>= 10.0.5)
- PowerShellStandard.Library (>= 5.1.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
v3.229.11:
- Now uses Nerdbank.GitVersioning for automatic versioning (synchronized with LogicMonitor.Api)
- Updated Microsoft.Extensions.Logging packages to 10.0.1
- Fixed logger disposal issue in cmdlets
- Underlying LogicMonitor.Api now supports JSON export/import for LogicModules