Instalation and Setup
Installation
You can install the Logic.Monitor PowerShell module directly from the PowerShell Gallery:
Install-Module -Name "Logic.Monitor"
To ensure you have the latest version, you can run:
Update-Module -Name "Logic.Monitor"
Authentication
Before using any module commands, you need to connect to your LogicMonitor portal. You have two options for authentication:
Direct Connection (LMv1|BearerToken)
Connect-LMAccount -AccessId "your_access_id" -AccessKey "your_access_key" -AccountName "your_portal"
Connect-LMAccount -BearerToken "your_bearer_token" -AccountName "your_portal"
Using Cached Credentials
The Logic.Monitor module includes built-in credential caching to simplify managing multiple portal connections. Using Microsoft’s SecretManagement module, you can securely store and access your LogicMonitor credentials without repeatedly entering them.
How It Works
When you first use the credential caching feature, you’ll be prompted to set up a secure local vault by creating a password. This vault safely stores your LogicMonitor portal credentials, allowing quick and secure access across multiple sessions.
- First, cache your credentials:
New-LMCachedAccount -AccessId "your_access_id" -AccessKey "your_access_key" -AccountName "your_portal"
- Then connect using cached credentials:
Connect-LMAccount -UseCachedCredential
# Select from multiple cached portalsEnter the number for the cached credential you wish to use:0) production-portal1) staging-portal
This approach:
- Securely stores multiple portal credentials
- Eliminates the need to handle sensitive information in scripts
- Provides a simple selection interface for multiple portals
- Leverages industry-standard encryption via SecretManagement
Basic Usage
Here are some common commands to get you started:
List Available Commands
Get-Command -Module "Logic.Monitor"
Working with Devices
# Get all devicesGet-LMDevice
# Get a specific device by nameGet-LMDevice -Name "device.example.com"
# Get devices matching a patternGet-LMDevice -DisplayName "corp*"
Working with Alerts
# Get active alertsGet-LMAlert
# Get alerts with specific filters (2=warning, 3=error, 4=critical)Get-LMAlert -Filter "severity -eq '2'"
Next Steps
- Check out the Command Reference for detailed information about all available commands
- View Examples for more complex usage scenarios
- Learn about Advanced Filtering capabilities