Skip to content

Pipeline Support

Many Logic.Monitor cmdlets support pipeline input, allowing you to chain commands together for more efficient automation. This guide demonstrates common pipeline patterns and examples.

Terminal window
# Get all devices and update their properties
Get-LMDevice -Filter "displayName -contains 'web'" |
Set-LMDevice -Properties @{"environment" = "production"}
# Remove multiple devices
Get-LMDevice -Filter "status -eq 'dead'" | Remove-LMDevice -Confirm:$false
Terminal window
# Acknowledge multiple alerts
Get-LMAlert -Severity 'Critical' |
New-LMAlertAck -Note "Investigating performance issues"
# Add notes to alerts
Get-LMAlert -Filter "resourceTemplateName -eq 'VMware'" |
New-LMAlertNote -Note "Escalated to VMware team"
Terminal window
# Copy properties between devices
Get-LMDevice -Name "template-server" |
Select-Object -ExpandProperty customProperties |
Set-LMDevice -Id 123 -Properties $_
# Update multiple device groups
Get-LMDeviceGroup -Filter "parentId -eq 0" |
Set-LMDeviceGroup -Properties @{"monitoring_level" = "premium"}
Terminal window
# Find and update devices, then add them to a group
Get-LMDevice -Filter "displayName -contains 'web'" |
Set-LMDevice -Properties @{"environment" = "production"} |
Add-LMDeviceToGroup -GroupName "Production Web Servers"
# Process alerts with multiple actions
Get-LMAlert -Filter "severity -eq 'Critical'" |
ForEach-Object {
$_ | New-LMAlertAck -Note "Auto-acknowledged"
$_ | New-LMAlertNote -Note "Escalating to on-call team"
$_ | New-LMAlertEscalation
}
Terminal window
# Process specific properties
Get-LMDevice |
Where-Object { $_.properties.environment -eq "production" } |
ForEach-Object {
$_ | Set-LMDevice -Properties @{
"sla_tier" = "high"
"backup_enabled" = "true"
}
}
# Batch processing with Select-Object
Get-LMAlert -Filter "ackTime -eq '$null'" |
Select-Object -First 10 |
New-LMAlertAck -Note "Batch acknowledgment"
  1. Use ValueFromPipelineByPropertyName

    Terminal window
    # Commands that accept pipeline input by property name
    Get-LMDevice | Select-Object id, name | Remove-LMDevice
  2. Handle Large Datasets

    Terminal window
    # Process items in batches
    Get-LMDevice |
    Select-Object -First 1000 |
    ForEach-Object -Parallel {
    $_ | Set-LMDevice -Properties @{"updated" = "true"}
    } -ThrottleLimit 5
  3. Error Handling in Pipelines

    Terminal window
    Get-LMDevice -Filter "status -eq 'dead'" |
    ForEach-Object {
    try {
    $_ | Remove-LMDevice -ErrorAction Stop
    Write-Host "Removed device: $($_.displayName)"
    }
    catch {
    Write-Error "Failed to remove $($_.displayName): $_"
    }
    }

Here are some commonly used cmdlets that support pipeline input:

  • Device Management

    • Set-LMDevice
    • Remove-LMDevice
    • Add-LMDeviceToGroup
  • Alert Management

    • New-LMAlertAck
    • New-LMAlertNote
    • New-LMAlertEscalation
  • Group Management

    • Set-LMDeviceGroup
    • Remove-LMDeviceGroup
    • Copy-LMDevicePropertyToGroup

To check if a cmdlet supports pipeline input, use:

Terminal window
Get-Help Logic.Monitor -Full | Select-Object -ExpandProperty parameters |
Where-Object { $_.ValueFromPipeline -or $_.ValueFromPipelineByPropertyName }