stevevillardi / Logic.Monitor

LogicMonitor PowerShell Module for automating LM Portal tasks using APIv3
https://www.powershellgallery.com/packages/Logic.Monitor
Mozilla Public License 2.0
23 stars 3 forks source link

Create SDT cmdlets for Adding,Updating and Removing SDT configurations #14

Closed stevevillardi closed 10 months ago

stevevillardi commented 10 months ago

User request from community (https://community.logicmonitor.com/lm-tech-talk-33/logic-monitor-powershell-module-3562?postid=13393#post13393):

Hello @Steve Villardi - great work! Just a short question regarding this. We have several Windows System which we schedule from Task to reboot frequently. We thought to put some lines to the script to tell LM to put that Machine to that point to a short SDT. But i don´t find a module to set. Is that correct?

Add New-LMDeviceSDT, Set-LMDeviceSDT and Remove-LMDeviceSDT to the cmdlet list.

stevevillardi commented 10 months ago

Pending successful build testing for release in version 4.5:

4.5 Changes

New Commands:

New-LMDeviceSDT: New command to create device level SDT. Supports oneTime, daily, weekly, monthly and dayOfMonth occurrences. New-LMDeviceGroupSDT: New command to create device group level SDT. Supports oneTime, daily, weekly, monthly and dayOfMonth occurrences. New-LMDeviceDatasourceSDT: New command to create a datasource level SDT for a targeted device. Supports oneTime, daily, weekly, monthly and dayOfMonth occurrences. New-LMDeviceDatasourceInstanceSDT: New command to create an instance level SDT for a targeted device. Supports oneTime, daily, weekly, monthly and dayOfMonth occurrences.

Set-LMSDT: New command to manage existing scheduled SDT windows. Supports pipeline input from Get-LMSDT, Get-LMDeviceSDT and Get-LMDeviceGroupSDT.

Remove-LMSDT: New command to delete scheduled SDT windows. Supports pipeline input from Get-LMSDT, Get-LMDeviceSDT and Get-LMDeviceGroupSDT.

Updated Commands:

Get-SDT: Added custom object typing for returned results. Get-LMDeviceSDT: Added custom object typing for returned results. Get-LMDeviceGroupSDT: Added custom object typing for returned results.

stevevillardi commented 10 months ago

Usage examples:

#Example usage New-LMDeviceSDT
#OneTime SDT window
New-LMDeviceSDT -DeviceId 2798 -StartDate (Get-Date) -EndDate (Get-Date).AddHours(12) -Comment "Quick Reboot"

#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"

#Weekly 30-minute SDT window every Monday
New-LMDeviceSDT -DeviceId 2798 -StartHour 12 -StartMinute 0  -EndHour 12 -EndMinute 30  -WeekDay Monday -Comment "Patch Window"

#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"

#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"

#Example usage Set-LMSDT
#Update SDT to the 5th day of the month
Set-LMSDT -id HG_77 -DayOfMonth 5 -Comment "New Patch Window (5th of each month)"

#Example usage Remove-LMSDT
#Update SDT to the 5th day of the month
Remove-LMSDT -id HG_77