### Create, Download, and Silently Install a LogicMonitor Collector Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/EXAMPLES.md This snippet demonstrates how to create a new collector, download its installer, and then silently install it on a Windows machine. Ensure you replace placeholder values with your actual account details and desired paths. ```powershell #Connect to LogicMonitor account Connect-LMAccount -AccountName "" -AccessId "" -AccessKey "" #Create new collector and download the installer $Collector = New-LMCollector -Description "" $FilePath = Get-LMCollectorInstaller -Id $Collector.Id -Size "medium" -OSandArch "Win64" -DownloadPath "C:\temp" #Install the collector silently .\$FilePath /q /a:administrator /p:'password' #Disconnect from LogicMonitor account Disconnect-LMAccount ``` -------------------------------- ### Install LogicMonitor PowerShell Module Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/README.md Installs the Logic.Monitor module from the PowerShell Gallery. Ensure you have an active internet connection. ```powershell Install-Module -Name "Logic.Monitor" ``` -------------------------------- ### Retrieve all property sources Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMPropertySource.md This example shows how to retrieve all property sources from LogicMonitor. ```APIDOC ## Get-LMPropertySource ### Description Retrieves all property sources from LogicMonitor. ### Method GET ### Endpoint /propertySources ### Parameters #### Query Parameters - **BatchSize** (Int32) - Optional - The number of results to return per request. Must be between 1 and 1000. Defaults to 1000. ### Response #### Success Response (200) - **propertySources** (Array) - A list of LogicMonitor.PropertySource objects. ### Response Example ```json { "propertySources": [ { "id": 1, "name": "Windows-Properties", "description": "Default properties for Windows devices" } ] } ``` ``` -------------------------------- ### Comment-Based Help for PowerShell Functions Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/CONTRIBUTOR_GUIDELINES.md Provides an example of comprehensive comment-based help for a PowerShell function, including synopsis, description, parameter details, examples, and output types. This is mandatory for all functions. ```powershell <# .SYNOPSIS Retrieves user information from the system. .DESCRIPTION The Get-UserInfo function retrieves detailed information about users in the system based on specified filters. .PARAMETER Username The username to retrieve information for. .EXAMPLE Get-UserInfo -Username "john.doe" Retrieves information for user john.doe. .OUTPUTS System.Object. Returns a custom object with user properties. #> ``` -------------------------------- ### Retrieve all diagnostic sources Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMDiagnosticSource.md This example shows how to retrieve all available diagnostic sources. ```APIDOC ## Get-LMDiagnosticSource (All) ### Description Retrieves all diagnostic sources from LogicMonitor. ### Method GET (Conceptual - PowerShell cmdlet) ### Endpoint Not Applicable (PowerShell cmdlet) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```powershell Get-LMDiagnosticSource ``` ### Response #### Success Response (200) - **DiagnosticSource** (LogicMonitor.DiagnosticSource[]) - Returns an array of LogicMonitor.DiagnosticSource objects. #### Response Example ```json [ { "id": 123, "name": "ExampleSource1", "description": "Description for source 1." }, { "id": 456, "name": "ExampleSource2", "description": "Description for source 2." } ] ``` ``` -------------------------------- ### Create Graph Using Datasource Name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMDatasourceGraph.md Use this example when you have the datasource name. Ensure you have a $graphConfig object defined. ```powershell #Create graph using datasource name New-LMDatasourceGraph -RawObject $graphConfig -DatasourceName "MyDatasource" ``` -------------------------------- ### Retrieve all event sources Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMEventSource.md This example shows how to retrieve all event sources from LogicMonitor. ```APIDOC ## Get-LMEventSource ### Description Retrieves all event sources from LogicMonitor. ### Method GET ### Endpoint /eventSources ### Parameters #### Query Parameters - **batchSize** (Int32) - Optional - The number of results to return per request. Defaults to 1000. ### Response #### Success Response (200) - **eventSources** (Array) - A list of event source objects. ### Response Example ```json { "eventSources": [ { "id": 1, "name": "Windows-Events", "description": "Monitors Windows Event Logs." } ] } ``` ``` -------------------------------- ### Retrieve all remediation sources Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMRemediationSource.md This example shows how to retrieve all available remediation sources by calling the cmdlet without any parameters. ```APIDOC ## Get-LMRemediationSource ### Description Retrieves all remediation sources from LogicMonitor. ### Method GET ### Endpoint /rest/v1/remediationsources ### Parameters #### Query Parameters - **batchSize** (Int32) - Optional - The number of results to return per request. Must be between 1 and 1000. Defaults to 1000. ### Response #### Success Response (200) - **items** (Array[LogicMonitor.RemediationSource]) - A list of remediation source objects. ### Response Example ```json { "items": [ { "id": 1, "name": "ExampleSource1", "description": "This is the first example remediation source." }, { "id": 2, "name": "ExampleSource2", "description": "This is the second example remediation source." } ] } ``` ``` -------------------------------- ### Copy LMDashboard Example Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Clone an existing dashboard by specifying its ID, a new name, parent group, and description. ```powershell #Clone an existing dashboard with id 25 but place it in a different group with a new description Copy-LMDashboard -Name NewClonedDashboard -DasbhaordId 25 -ParentGroupId 2 -Description "New Cloned Dashboard" ``` -------------------------------- ### Retrieve Overview Graphs by Name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMDatasourceOverviewGraph.md Use this example to retrieve overview graphs by their name from a specified datasource. ```powershell Get-LMDatasourceOverviewGraph -Name "System Overview" -DataSourceName "CPU" ``` -------------------------------- ### Retrieve all escalation chains Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMEscalationChain.md This example shows how to retrieve all escalation chains by calling the Get-LMEscalationChain cmdlet without any parameters. ```APIDOC ## Get-LMEscalationChain ### Description Retrieves all escalation chains from LogicMonitor. ### Method GET ### Endpoint /escalationChains ### Parameters #### Query Parameters - **batchSize** (Int32) - Optional - The number of results to return per request. Must be between 1 and 1000. Defaults to 1000. ### Response #### Success Response (200) - **escalationChains** (Array) - A list of escalation chain objects. ### Response Example ```json { "escalationChains": [ { "id": 1, "name": "Default Chain", "description": "Default escalation chain", "order": 1, "enabled": true } ] } ``` ``` -------------------------------- ### Retrieve all log partition retentions Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMLogPartitionRetention.md This example shows how to retrieve all log partition retentions available in your LogicMonitor account. ```APIDOC ## Get-LMLogPartitionRetention ### Description Retrieves LM Log Partition Retentions from LogicMonitor. It can retrieve all log partition retentions available to the account. ### Method GET ### Endpoint /log/partition/retention ### Parameters #### Query Parameters None ### Request Example ```powershell Get-LMLogPartitionRetention ``` ### Response #### Success Response (200) - **retentionDays** (integer) - The number of days the logs are retained. - **partitionName** (string) - The name of the log partition. #### Response Example ```json { "retentionDays": 30, "partitionName": "default" } ``` ``` -------------------------------- ### Get Logic Module Metadata Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMLogicModuleMetadata.md Retrieves all Logic Module metadata. This is a basic usage example. ```powershell Get-LMLogicModuleMetadata ``` -------------------------------- ### Retrieve all cost optimization recommendations Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMCostOptimizationRecommendation.md This example shows how to retrieve all available cost optimization recommendations by calling the cmdlet without any parameters. ```APIDOC ## Get-LMCostOptimizationRecommendation ### Description Retrieves all cloud cost optimization recommendations from a connected LogicMonitor portal. ### Method GET (Implicit, as it's a PowerShell cmdlet retrieving data) ### Endpoint (Not directly applicable for PowerShell cmdlets, but conceptually related to an API endpoint for recommendations) ### Parameters #### Query Parameters - **BatchSize** (Int32) - Optional - The number of results to return per request. Must be between 1 and 1000. Defaults to 50. ### Request Example ```powershell Get-LMCostOptimizationRecommendation ``` ### Response #### Success Response (200) - **LogicMonitor.CostOptimizationRecommendations** objects are returned. #### Response Example (Response structure depends on the LogicMonitor API, typically a list of recommendation objects) ``` -------------------------------- ### Retrieve Operations Notes by Tag Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMOpsNote.md Filter and retrieve operations notes by specifying a relevant tag. For example, to get notes related to 'Maintenance', use the '-Tag' parameter. ```powershell Get-LMOpsNote -Tag "Maintenance" ``` -------------------------------- ### Update One-Time SDT Entry Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Set-LMSDT.md Use this example to update an existing one-time SDT entry by providing its ID, new start and end dates, and an optional comment. ```powershell Set-LMSDT -Id 123 -StartDate "2024-01-01 00:00" -EndDate "2024-01-02 00:00" -Comment "Extended maintenance" ``` -------------------------------- ### Create a new LogicMonitor push metric instance Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMPushMetricInstance.md This example demonstrates how to create a new instance with specified parameters and add it to an existing instances array. It requires the instances array, instance name, display name, description, properties, and datapoints. ```powershell $instances = New-LMPushMetricInstance -InstancesArrary $instances -InstanceName "Instance1" -InstanceDisplayName "Instance 1" -InstanceDescription "This is instance 1" -InstanceProperties @{Property1 = "Value1"; Property2 = "Value2"} -Datapoints $datapoints ``` -------------------------------- ### Copy Device with Custom Display Name and Description Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Copy-LMDevice.md This example demonstrates how to copy a device and specify a custom display name and description for the new device. The source device object is still required. ```powershell #Copy a device with custom display name and description Copy-LMDevice -Name "NewDevice" -DisplayName "New Display Name" -Description "New device description" -DeviceObject $deviceObject ``` -------------------------------- ### Get Custom Columns for Alerts - PowerShell Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Retrieve alerts with up to 5 additional custom properties using the -customColumns parameter. This functionality is available for all alert queries starting with portal version 222. ```powershell Get-LMAlert -customColumns "system.hostStatus,custom.prop,other.prop" ``` -------------------------------- ### Migrate Website Check to Uptime Device Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/ConvertTo-LMUptimeDevice.md This example demonstrates how to pipe the output of Get-LMWebsite to ConvertTo-LMUptimeDevice to create a new Uptime device with a specified name suffix. Ensure you have connected to your LogicMonitor account using Connect-LMAccount prior to execution. ```powershell Get-LMWebsite -Name "logicmonitor.com" | ConvertTo-LMUptimeDevice -NameSuffix "-uptime" ``` -------------------------------- ### Export Device Group Data to CSV with Datasource Filtering Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Export-LMDeviceData.md Exports monitoring data for a device group to CSV format, including only datasources that match the specified filter pattern. This example filters for datasources starting with 'CPU'. ```powershell Export-LMDeviceData -DeviceGroupName "Production" -DatasourceIncludeFilter "CPU*" -ExportFormat csv ``` -------------------------------- ### Export configurations from a single device Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Export-LMDeviceConfigBackup.md Use this example to export configurations for an individual device. Provide the correct DeviceId and a valid output path. ```powershell Export-LMDeviceConfigBackup -DeviceId 1 -Path "export-report.csv" ``` -------------------------------- ### Install Development Modules and Clone Repository Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/CONTRIBUTOR_GUIDELINES.md Installs necessary PowerShell modules like Pester and PSScriptAnalyzer, and clones the module repository. Ensure you have PowerShell 5.1 or Core 7.x installed. ```powershell Install-Module -Name Pester -MinimumVersion 5.0.0 -Force Install-Module -Name PSScriptAnalyzer -Force git clone https://github.com/YOUR-USERNAME/powershell-module.git cd powershell-module ./scripts/setup-dev-environment.ps1 ``` -------------------------------- ### Create New LogicMonitor User Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMUser.md This example demonstrates how to create a new LogicMonitor user with specified username, email, password, role, and view access. Ensure all required parameters are provided. ```powershell New-LMUser -Username "john.doe" -Email "john.doe@example.com" -Password "P@ssw0rd" -RoleNames @("admin") -Views @("Dashboards", "Reports") ``` -------------------------------- ### New-LMDevice Cmdlet Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMDevice.md Creates a new LogicMonitor device with specified configuration settings. ```APIDOC ## New-LMDevice ### Description The New-LMDevice function creates a new device in LogicMonitor with specified configuration settings. ### Syntax ```powershell New-LMDevice [-Name] [-DisplayName] [[-Description] ] [-PreferredCollectorId] [[-PreferredCollectorGroupId] ] [[-AutoBalancedCollectorGroupId] ] [[-DeviceType] ] [[-Properties] ] [[-HostGroupIds] ] [[-Link] ] [[-DisableAlerting] ] [[-EnableNetFlow] ] [[-NetflowCollectorGroupId] ] [[-NetflowCollectorId] ] [[-LogCollectorGroupId] ] [[-LogCollectorId] ] [-ProgressAction ] [-WhatIf] [-Confirm] [] ``` ### Parameters #### -Name (String) The name of the device. This parameter is mandatory. #### -DisplayName (String) The display name of the device. This parameter is mandatory. #### -Description (String) The description of the device. #### -PreferredCollectorId (Int32) The ID of the preferred collector for the device. This parameter is mandatory. #### -PreferredCollectorGroupId (Int32) The ID of the preferred collector group for the device. #### -AutoBalancedCollectorGroupId (Int32) The ID of the auto-balanced collector group for the device. #### -DeviceType (Int32) The type of the device. Defaults to 0. #### -Properties (Hashtable) A hashtable of custom properties for the device. #### -HostGroupIds (String[]) An array of host group IDs. Dynamic group IDs will be ignored. #### -Link (String) The link associated with the device. #### -DisableAlerting (Boolean) Whether to disable alerting for the device. #### -EnableNetFlow (Boolean) Whether to enable NetFlow for the device. #### -NetflowCollectorGroupId (Int32) The ID of the NetFlow collector group. #### -NetflowCollectorId (Int32) The ID of the NetFlow collector. #### -LogCollectorGroupId (Int32) The ID of the log collector group. #### -LogCollectorId (Int32) The ID of the log collector. ### Examples #### EXAMPLE 1 ```powershell #Create a new device New-LMDevice -Name "server1" -DisplayName "Server 1" -PreferredCollectorId 123 -Properties @{"location"="datacenter1"} ``` ``` -------------------------------- ### Create Overview Graph using Datasource Name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMDatasourceOverviewGraph.md Use this example to create an overview graph when you know the datasource name. Ensure you have a valid graph configuration object stored in $graphConfig. ```powershell #Create overview graph using datasource name New-LMDatasourceOverviewGraph -RawObject $graphConfig -DatasourceName "MyDatasource" ``` -------------------------------- ### Invoke Universal API Request (GET) Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Makes a generic GET request to a LogicMonitor API endpoint. Useful for accessing various resources. ```powershell Invoke-LMAPIRequest -ResourcePath "/setting/integrations" -Method GET -QueryParams @{ size = 500 } ``` -------------------------------- ### Initialize LM POV Setup Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Fixes an issue with setting up LM logs to ensure correct appliesTo logic for imported Windows Logs DS. ```powershell Initialize-LMPOVSetup ``` -------------------------------- ### Download Windows Collector Installer Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMCollectorInstaller.md Use this snippet to download a Windows collector installer by its ID, specifying the size, OS architecture, and download path. ```powershell Get-LMCollectorInstaller -Id 123 -Size medium -OSandArch Win64 -DownloadPath "C:\Downloads" ``` -------------------------------- ### Example Usage of Set-LMDeviceGroupDatasourceAlertSetting Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Set-LMDeviceGroupDatasourceAlertSetting.md This example demonstrates updating alert settings for a specific datapoint within a device group datasource. The alert expression and transition intervals are specified. ```powershell Set-LMDeviceGroupDatasourceAlertSetting -DatasourceName "CPU Usage" -Name "Server Group" -DatapointName "cpu.user" -AlertExpression "(01:00 02:00) > 90" -AlertClearTransitionInterval 5 -AlertTransitionInterval 10 -AlertForNoData 0 ``` -------------------------------- ### Create Device SDT Windows with New-LMDeviceSDT Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Examples demonstrate creating one-time, daily, weekly, monthly, and specific day-of-month SDT windows for a device. Ensure the correct parameters for date, time, and recurrence are used. ```powershell #Example usage New-LMDeviceSDT #OneTime SDT window New-LMDeviceSDT -DeviceId 2798 -StartDate (Get-Date) -EndDate (Get-Date).AddHours(12) -Comment "Quick Reboot" ``` ```powershell #Daily 30-minute SDT window from 12:00 to 12:30 New-LMDeviceSDT -DeviceId 2798 -DeviceId 2798 -StartHour 12 -StartMinute 0 -EndHour 12 -EndMinute 30 -Comment "Daily Reboot" ``` ```powershell #Weekly 30-minute SDT window every Monday New-LMDeviceSDT -DeviceId 2798 -StartHour 12 -StartMinute 0 -EndHour 12 -EndMinute 30 -WeekDay Monday -Comment "Patch Window" ``` ```powershell #Monthly 30-minute SDT window every 1st day of the month New-LMDeviceSDT -DeviceId 2798 -StartHour 12 -StartMinute 0 -EndHour 12 -EndMinute 30 -DayOfMonth 1 -Comment "Patch Window" ``` ```powershell #Monthly 30-minute SDT window on the 1st Monday of every month New-LMDeviceSDT -DeviceId 2798 -StartHour 12 -StartMinute 0 -EndHour 12 -EndMinute 30 -WeekDay Monday -WeekOfMonth First -Comment "Patch Window" ``` -------------------------------- ### Download Linux Collector Installer with Early Access Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMCollectorInstaller.md Use this snippet to download a Linux collector installer by its name, enabling the Early Access version and specifying the OS architecture. ```powershell Get-LMCollectorInstaller -Name "Collector1" -OSandArch Linux64 -UseEA $true ``` -------------------------------- ### Generate Example CSV for Device Group Import Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Import-LMDeviceGroupsFromCSV.md Run this command to generate a sample CSV file that can be used as a template for importing device groups. This is useful for understanding the required CSV format. ```powershell Import-LMDeviceGroupsFromCSV -GenerateExampleCSV ``` -------------------------------- ### Collect Config Using Datasource Name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Invoke-LMDeviceConfigSourceCollection.md Use this example to collect configuration data by specifying the device name, datasource name, and instance ID. ```powershell #Collect config using datasource name Invoke-LMDeviceConfigSourceCollection -Name "Device1" -DatasourceName "Config" -InstanceId "123" ``` -------------------------------- ### Create One-Time SDT Entry Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMDeviceDatasourceInstanceSDT.md Use this to create a one-time SDT entry. Specify the comment, start and end dates, and the device datasource instance ID. The start and end times are also required. ```powershell New-LMDeviceDatasourceInstanceSDT -Comment "Test SDT Instance" -StartDate (Get-Date) -EndDate (Get-Date).AddDays(7) -StartHour 8 -StartMinute 30 -DeviceDataSourceInstanceId 1234 ``` -------------------------------- ### Initialize LM POV Setup Dynamic Groups Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Defines dynamic groups for LogicMonitor's POV setup. These groups are provisioned as part of the CleanupDynamicGroups parameter and cover various resource types and statuses. ```powershell "All Devices" = 'true()' "AWS Resources" = 'isAWSService()' "Azure Resources" = 'isAzureService()' "GCP Resources" = 'isGCPService()' "K8s Resources" = 'system.devicetype == "8"' "Dead Devices" = 'system.hoststatus == "dead" || system.hoststatus == "dead-collector" || system.gcp.status == "TERMINATED" || system.azure.status == "PowerState/stopped" || system.aws.stateName == "terminated"' "Palo Alto" = 'hasCategory("PaloAlto")' "Cisco ASA" = 'hasCategory("CiscoASA")' "Logs Enabled Devices" = 'hasPushModules("LogUsage")' "Netflow Enabled Devices" = 'isNetflow()' "Cisco UCS" = 'hasCategory("CiscoUCSFabricInterconnect") || hasCategory("CiscoUCSManager")' "Oracle" = 'hasCategory("OracleDB")' "Domain Controllers" = 'hasCategory("MicrosoftDomainController")' "Exchange Servers" = 'hasCategory("MSExchange")' "IIS" = 'hasCategory("MicrosoftIIS")' "Citrix XenApp" = 'hasCategory("CitrixBrokerActive") || hasCategory("CitrixMonitorServiceV2") || hasCategory("CitrixLicense") || hasCategory("CitrixEUEM")' ``` -------------------------------- ### Collect Config Using Datasource ID Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Invoke-LMDeviceConfigSourceCollection.md Use this example to collect configuration data by specifying the device ID, datasource ID, and instance ID. ```powershell #Collect config using datasource ID Invoke-LMDeviceConfigSourceCollection -Id 456 -DatasourceId 789 -InstanceId "123" ``` -------------------------------- ### Get instance count for a device by name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMDeviceInstanceList.md Use this snippet to get only the total count of instances for a device identified by its name. Set '-CountOnly' to $true to retrieve the count instead of instance details. Requires a valid device name. ```powershell Get-LMDeviceInstanceList -Name "Production-Server" -CountOnly $true ``` -------------------------------- ### Create Resource and Send Metric Data - Send-LMPushMetric Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Send-LMPushMetric.md Use this example to create a new resource and send metric data for specified instances using a datasource ID. Ensure the $Instances variable is populated with data from New-LMPushMetricInstance. ```powershell Send-LMPushMetric -NewResourceHostName "NewResource" -NewResourceDescription "New Resource Description" -ResourceIds @{"system.deviceId"="12345"} -ResourceProperties @{"Property1"="Value1"} -DatasourceId "123" -Instances $Instances ``` -------------------------------- ### Create Enhanced Network Scan with Parameters Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMEnhancedNetScan.md Use this example to create a new enhanced network scan, specifying all available parameters for detailed configuration. ```powershell New-LMEnhancedNetScan -CollectorId "12345" -Name "MyNetScan" -NetScanGroupName "Group1" -CustomCredentials $customCreds -Filters $filters -Description "This is a network scan" -ExcludeDuplicateType "1" -Method "enhancedScript" -NextStart "manual" -NextStartEpoch "0" -GroovyScript "script" -CredentialGroupId "67890" -CredentialGroupName "Group2" ``` -------------------------------- ### Get Report Execution Task Status by Report ID Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMReportExecutionTask.md Use this snippet to get the execution status for a specific report and task combination using the report's ID. The task ID is typically obtained from a previous Invoke-LMReportExecution command. ```powershell Invoke-LMReportExecution -Id 42 | Select-Object -ExpandProperty taskId | Get-LMReportExecutionTask -ReportId 42 ``` -------------------------------- ### Get Report Execution Task Status by Report Name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMReportExecutionTask.md This snippet demonstrates how to check the task status for a report using its name. First, invoke the report execution to get the task object, then use Get-LMReportExecutionTask with the report name and the task ID. ```powershell $task = Invoke-LMReportExecution -Name "Monthly Availability" Get-LMReportExecutionTask -ReportName "Monthly Availability" -TaskId $task.taskId ``` -------------------------------- ### Create a New LogicMonitor Service Template Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMServiceTemplate.md Use this cmdlet to create a new LogicMonitor Service template with basic parameters like name and description. ```powershell New-LMServiceTemplate -Name "Application Services by Site" -Description "Default LM service template for application services" ``` -------------------------------- ### Get Device Alerts Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Added pipeline support for Get-LMDeviceAlerts. ```powershell Get-LMDeviceAlerts ``` -------------------------------- ### New-LMUptimeWebStep Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMUptimeWebStep.md Creates a LogicMonitor Uptime web step definition. This cmdlet generates a hashtable describing a single web step compatible with the New-LMUptimeDevice and Set-LMUptimeDevice cmdlets. ```APIDOC ## New-LMUptimeWebStep ### Description Creates a LogicMonitor Uptime web step definition. This cmdlet generates a hashtable describing a single web step compatible with the New-LMUptimeDevice and Set-LMUptimeDevice cmdlets. ### Syntax #### External (Default) ```powershell New-LMUptimeWebStep [-Name ] [-Url ] [-HttpMethod ] [-HttpVersion ] -Type [-Enable ] [-UseDefaultRoot ] [-Schema ] [-FollowRedirection ] [-FullPageLoad ] [-RequireAuth ] [-AuthType ] [-AuthUserName ] [-AuthPassword ] [-AuthDomain ] [-HttpHeaders ] [-HttpBody ] [-RequestType ] [-ResponseType ] [-MatchType ] [-Keyword ] [-InvertMatch] [-StatusCode ] [-Path ] [-Label ] [-Description ] [-TimeoutInSeconds ] [-PostDataEditType ] [] ``` #### Internal ```powershell New-LMUptimeWebStep [-Name ] [-Url ] [-HttpMethod ] [-HttpVersion ] -Type [-Enable ] [-UseDefaultRoot ] [-Schema ] [-FollowRedirection ] [-FullPageLoad ] [-RequireAuth ] [-AuthType ] [-AuthUserName ] [-AuthPassword ] [-AuthDomain ] [-HttpHeaders ] [-HttpBody ] [-RequestType ] [-ResponseType ] [-MatchType ] [-Keyword ] [-InvertMatch] [-StatusCode ] [-Path ] [-Label ] [-Description ] [-TimeoutInSeconds ] [-PostDataEditType ] [-ResponseScript ] [-RequestScript ] [] ``` ### Parameters #### -Name Step name. Defaults to "__step0". - **Name** (String) - Optional - Defaults to "__step0" #### -Url Relative or absolute URL to execute. Defaults to empty string. - **Url** (String) - Optional - Defaults to None #### -HttpMethod HTTP method executed by the step. Valid values: GET, HEAD, POST. Defaults to GET. - **HttpMethod** (String) - Optional - Defaults to GET #### -HttpVersion HTTP protocol version. Valid values: 1, 1.1. Defaults to 1.1. - **HttpVersion** (String) - Optional - Defaults to 1.1 #### -Type Controls whether the step is treated as external (config) or internal (script). External set uses Type "config"; internal may use "script" or "config". - **Type** (String) - Required #### -Enable Indicates whether the step is enabled. Defaults to $true. - **Enable** (Boolean) - Optional - Defaults to True #### -UseDefaultRoot Indicates whether the default root should be used. Defaults to $true. - **UseDefaultRoot** (Boolean) - Optional - Defaults to True #### -Schema HTTP schema value (http or https). Defaults to https. - **Schema** (String) - Optional - Defaults to Https #### -FollowRedirection Indicates whether redirects are automatically followed. Defaults to $true. - **FollowRedirection** (Boolean) - Optional - Defaults to True ### Examples #### EXAMPLE 1 ```powershell New-LMUptimeWebStep -Type External -Name '__home' -Url '/' -Keyword 'Welcome' -StatusCode '200' ``` #### EXAMPLE 2 ```powershell New-LMUptimeWebStep -Type Internal -RequestType script -RequestScript $scriptBlock ``` ``` -------------------------------- ### Get Device Alert Settings Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Added pipeline support for Get-LMDeviceAlertSettings. ```powershell Get-LMDeviceAlertSettings ``` -------------------------------- ### Export configurations from a device group Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Export-LMDeviceConfigBackup.md Use this example to export configurations for all devices within a specific device group. Ensure you provide the correct DeviceGroupId and a valid output path. ```powershell Export-LMDeviceConfigBackup -DeviceGroupId 2 -Path "export-report.csv" ``` -------------------------------- ### Generate Example CSV for Device Import Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Import-LMDevicesFromCSV.md Generates a sample CSV file that can be used as a template for importing devices. This is useful for understanding the required CSV format. ```powershell Import-LMDevicesFromCSV -GenerateExampleCSV ``` -------------------------------- ### Get Device Group Alerts Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Added pipeline support for Get-LMDeviceGroupAlerts. ```powershell Get-LMDeviceGroupAlerts ``` -------------------------------- ### Create External Uptime Web Step Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMUptimeWebStep.md Use this example to create a basic external web step. It specifies the type, name, URL, a keyword to look for in the response, and the expected HTTP status code. ```powershell New-LMUptimeWebStep -Type External -Name '__home' -Url '/' -Keyword 'Welcome' -StatusCode '200' ``` -------------------------------- ### Retrieve All Cost Optimization Recommendations Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMCostOptimizationRecommendation.md Use this command to retrieve all available cost optimization recommendations. Ensure you have authenticated with LogicMonitor first. ```powershell Get-LMCostOptimizationRecommendation ``` -------------------------------- ### Restore a Previously Deleted Device Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md This example shows how to restore a previously deleted device by first retrieving its ID and then using the Restore-LMRecentlyDeleted cmdlet. The -Confirm:$false parameter bypasses confirmation prompts. ```powershell # Restore a previously deleted device and confirm the operation Get-LMRecentlyDeleted -ResourceType device | Select-Object -First 1 -ExpandProperty id | Restore-LMRecentlyDeleted -Confirm:$false ``` -------------------------------- ### Get Collector Debug Results Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Retrieves the command output from a collector debug session. ```powershell Get-LMCollectorDebugResult ``` -------------------------------- ### Create Overview Graph using Datasource ID Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/New-LMDatasourceOverviewGraph.md Use this example to create an overview graph when you have the datasource ID. Ensure you have a valid graph configuration object stored in $graphConfig. ```powershell #Create overview graph using datasource ID New-LMDatasourceOverviewGraph -RawObject $graphConfig -DatasourceId 123 ``` -------------------------------- ### Get NetScan Policy Executions Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Retrieves a list of executions for a specified NetScan policy. ```powershell Get-LMNetscanExecution ``` -------------------------------- ### Retrieve a diagnostic source by name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMDiagnosticSource.md This example demonstrates how to retrieve a diagnostic source by its name. ```APIDOC ## Get-LMDiagnosticSource -Name ### Description Retrieves a specific diagnostic source by its name. ### Method GET (Conceptual - PowerShell cmdlet) ### Endpoint Not Applicable (PowerShell cmdlet) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```powershell Get-LMDiagnosticSource -Name "Test_DiagnosticSource" ``` ### Response #### Success Response (200) - **DiagnosticSource** (LogicMonitor.DiagnosticSource) - Returns LogicMonitor.DiagnosticSource objects. #### Response Example ```json { "id": 456, "name": "Test_DiagnosticSource", "description": "A test diagnostic source." } ``` ``` -------------------------------- ### Example Output for Cached Credentials Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/README.md Illustrates the expected output when using cached credentials, showing a list of available cached accounts and prompting for selection. ```powershell #Example output when using cached credentials #Selection Number | Portal Name #0) portalname #1) portalnamesandbox #Enter the number for the cached credential you wish to use: 1 #Connected to LM portal portalnamesandbox using account ``` -------------------------------- ### Get Netscan Objects Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/RELEASENOTES.md Retrieves Netscan objects with a custom object type for easier handling. ```powershell Get-LMNetscan ``` -------------------------------- ### Enable monitoring using names Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Set-LMDeviceGroupDatasource.md Use this example to enable monitoring for a datasource on a device group by specifying their names. Ensure you have connected to your LogicMonitor account using Connect-LMAccount prior to running this command. ```powershell Set-LMDeviceGroupDatasource -Name "Production Servers" -DatasourceName "CPU" -StopMonitoring $false ``` -------------------------------- ### Get Topology Map Data by Name Source: https://github.com/logicmonitor/lm-powershell-module/blob/main/Documentation/Get-LMTopologyMapData.md Retrieves topology map data using its name. ```APIDOC ## Get-LMTopologyMapData -Name ### Description Retrieves the vertex and edge data for a specified topology map in LogicMonitor using its name. ### Method GET (conceptual, as this is a PowerShell cmdlet) ### Endpoint (Not applicable for PowerShell cmdlets) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```powershell Get-LMTopologyMapData -Name "Network-Topology" ``` ### Response #### Success Response (200) - **TopologyMapData** (LogicMonitor.TopologyMapData) - Contains vertex and edge data for the topology map. #### Response Example (Response structure depends on LogicMonitor.TopologyMapData object definition) ```