├── Enums └── Enums.ps1 ├── Examples ├── Example-MultipleServersOneGo.ps1 ├── Example-MultipleServersServices.ps1 ├── Example-PanelAccountPageSettings.ps1 ├── Example-PanelNotificationsPefromance.ps1 ├── Example-PanelNotificationsServices.ps1 ├── Example-PanelNotificationsStorage.ps1 └── Example-PulsewayCheck.ps1 ├── PSPulsewayManager.psd1 ├── PSPulsewayManager.psm1 ├── Private ├── PSRunspace.ps1 └── SupportFunctions.ps1 ├── Public ├── PulsewayAccount.ps1 ├── PulsewayManager.ps1 ├── PulsewayNotificationsPerformance.ps1 ├── PulsewayNotificationsServices.ps1 └── PulsewayNotificationsStorage.ps1 └── README.md /Enums/Enums.ps1: -------------------------------------------------------------------------------- 1 | Enum NotificationStatus { 2 | Enabled = 1; 3 | Disabled = 0; 4 | } 5 | Enum NotificationType { 6 | <# 7 | Accessing 8 | [NotificationType] $Day = [NotificationType]::Critical 9 | 1 -As [NotificationType] 10 | #> 11 | Critical = 3; 12 | Elevated = 2; 13 | Normal = 1; 14 | Low = 0; 15 | } 16 | Enum Status { 17 | No = 0; Yes = 1; 18 | } 19 | Enum PulsewayStatus { 20 | NotAvailable = 0; 21 | NotRunning = 1; 22 | Running = 2; 23 | } 24 | Enum DiskStatus { 25 | Enabled = 1; 26 | Disabled = 0; 27 | } -------------------------------------------------------------------------------- /Examples/Example-MultipleServersOneGo.ps1: -------------------------------------------------------------------------------- 1 | ### Following Example shows a way to change multiple servers in one go according to specified rules. 2 | 3 | #Install-Module PSPulsewayManager 4 | #Install-Module PSManageService 5 | Clear-Host 6 | Import-Module PSPulsewayManager -Force 7 | Import-Module PSManageService -Force 8 | 9 | $MeasureTotal = [System.Diagnostics.Stopwatch]::StartNew() # Timer Start 10 | 11 | $Exludes = '*-S-*', '*RD*', 'UAT*', 'PROD*', 'CLR-*', '*Clu1', '*s2d*', '*FileServer*' 12 | 13 | $Servers = Get-ADComputer -Filter { OperatingSystem -like 'Windows Server*' } -Properties OperatingSystem | Select-Object Name, DNSHostName, OperatingSystem 14 | foreach ($Exclude in $Exludes) { 15 | $Servers = $Servers | Where { $_.Name -notlike $Exclude } 16 | 17 | } 18 | 19 | $Servers = $Servers | Sort-Object Name 20 | $Services = Get-PSService -Computers $Servers.Name -Services 'Pulseway' -maxRunspaces 200 -Verbose 21 | $PulsewayUnavailable = $Services | Where { $_.Status -eq 'N/A' } 22 | $PulsewayRunning = $Services | Where { $_.Status -eq 'Running' } 23 | 24 | Write-Color 'Servers to process: ', $Servers.Count, ' servers running: ', $PulsewayRunning.Count, ' servers unavailable: ', $PulsewayUnavailable.Count -Color White, Yellow, White, Yellow, White, Yellow 25 | Write-Color 'Pulseway is running: ', $PulsewayRunning.Count -Color White, Green 26 | $PulsewayRunning | Format-Table -AutoSize 27 | Write-Color 'Pulseway is unavailable: ', $PulsewayUnavailable.Count -Color White, Red 28 | $PulsewayUnavailable | Format-Table -AutoSize 29 | 30 | 31 | foreach ($server in $PulsewayRunning.Computer) { 32 | Write-Color '[start]', ' Processing server: ', $Server, ' for ', 'CPU/Storage' -Color Green, White, Yellow, White, Yellow 33 | ### Change CPU 90% for 30 minutes for all servers, disable Below CPU 34 | Set-PulsewayCPUBelow -Computer $Server -SendNotificationOnBelowCPUUsage Disabled -BelowCPUUsagePercentage 10 -BelowCPUUsageTimeInterval 30 -PrioritySendNotificationOnBelowCPUUsage Normal #-Verbose 35 | Set-PulsewayCPUAbove -Computer $Server -SendNotificationOnCPUUsage Enabled -CPUUsagePercentage 90 -CPUUsageTimeInterval 30 -PrioritySendNotificationOnCPUUsage Critical #-Verbose 36 | ### Storage 20GB free - ELEVATED, Storage 10GB free - CRITICAL 37 | $ListDrives = @() 38 | $FindDrives = Get-Drive -Computer $server | Where { [int] $_.SizeGB -gt 25 } #| Where { $_.VolumeName -ne 'Temporary Storage' -and $_.VolumeName -ne 'Bek Volume' } 39 | # Set the settings for all drives for particular computer/server (Elevated) 40 | $DrivesElevated = Set-DriveSettings -Drive $FindDrives -Percentage 10 -Priority Elevated -SizeMB 20000 -UsePercentage No 41 | # Repeat process for same drives but make it critical 42 | $DrivesCritical = Set-DriveSettings -Drive $FindDrives -Percentage 10 -Priority Critical -SizeMB 10000 -UsePercentage No 43 | $ListDrives += $DrivesElevated 44 | $ListDrives += $DrivesCritical 45 | Set-PulsewayLocalDiskSpace -Computer $Server -Drives $ListDrives -SendNotificationOnLowHDDSpace Enabled #-Verbose 46 | Write-Color '[stop ]', ' Processing server: ', $Server, ' for ', 'CPU/Storage' -Color Red, White, Yellow, White, Yellow 47 | 48 | if ($Server -like 'WEU-*' -or $Server -like 'NEU-*') { 49 | ### disable RAM Monitoring 50 | Write-Color '[start]', ' Processing server: ', $Server, ' for ', 'RAM disabling' -Color Green, White, Yellow, White, Gray 51 | Set-PulsewayMemoryLow -Computer $Server -LowMemoryPercentage 5 -LowMemoryTimeInterval 30 -PrioritySendNotificationOnLowMemory Low -SendNotificationOnLowMemory Disabled #-Verbose 52 | Write-Color '[stop ]', ' Processing server: ', $Server, ' for ', 'RAM disabling' -Color White, Yellow, White, Gray 53 | 54 | } elseif ($Server -like '-P-*' -and $Server -notlike '*HOST*') { 55 | ### disable RAM Monitoring 56 | Write-Color '[start]', ' Processing server: ', $Server, ' for ', 'RAM disabling' -Color Green, White, Yellow, White, Gray 57 | Set-PulsewayMemoryLow -Computer $Server -LowMemoryPercentage 5 -LowMemoryTimeInterval 30 -PrioritySendNotificationOnLowMemory Low -SendNotificationOnLowMemory Disabled #-Verbose 58 | Write-Color '[stop ]', ' Processing server: ', $Server, ' for ', 'RAM disabling' -Color Red, White, Yellow, White, Gray 59 | 60 | } elseif ($Server -like '*HOST*') { 61 | ### RAM - 5% for 30 minutes - CRITICAL 62 | Write-Color '[start]', ' Processing server: ', $Server, ' for ', 'RAM 5% in 30 minutes' -Color Green, White, Yellow, White, Red 63 | Set-PulsewayMemoryLow -Computer $Server -LowMemoryPercentage 5 -LowMemoryTimeInterval 30 -PrioritySendNotificationOnLowMemory Critical -SendNotificationOnLowMemory Enabled #-Verbose 64 | Write-Color '[stop ]', ' Processing server: ', $Server, ' for ', 'RAM 5% in 30 minutes' -Color Red, White, Yellow, White, Red 65 | } else { 66 | ### disable RAM Monitoring 67 | Write-Color '[start]', ' Processing server: ', $Server, ' for ', 'RAM disabling' -Color Green, White, Yellow, White, Gray 68 | Set-PulsewayMemoryLow -Computer $Server -LowMemoryPercentage 5 -LowMemoryTimeInterval 30 -PrioritySendNotificationOnLowMemory Low -SendNotificationOnLowMemory Disabled #-Verbose 69 | Write-Color '[stop ]', ' Processing server: ', $Server, ' for ', 'RAM disabling' -Color Red, White, Yellow, White, Gray 70 | } 71 | 72 | Write-Color '[i] ', 'Pulseway Settings for ', $Server -Color Yellow, White, Yellow 73 | $RamMonitoring = Get-PulsewayMemoryLow -Computer $Server #-Verbose 74 | Write-color '[i] ', 'Ram settings: ', 'NotificationEnabled ', $RamMonitoring.NotificationEnabled, 75 | ' NotificationType ', $RamMonitoring.NotificationType, ' TimeInterval ', $RamMonitoring.TimeInterval, 76 | ' Percentage ', $RamMonitoring.Percentage -Color Yellow, White, Yellow, Gray, Yellow, Gray, Yellow, Gray, Yellow, Gray 77 | $CpuBelow = Get-PulsewayCPUBelow -Computer $Server 78 | Write-color '[i] ', 'CPU Below settings: ', 'NotificationEnabled ', $CpuBelow.NotificationEnabled, 79 | ' NotificationType ', $CpuBelow.NotificationType, ' TimeInterval ', $CpuBelow.TimeInterval, 80 | ' Percentage ', $CpuBelow.Percentage -Color Yellow, White, Yellow, Gray, Yellow, Gray, Yellow, Gray, Yellow, Gray 81 | $CpuAbove = Get-PulsewayCPUAbove -Computer $Server 82 | Write-color '[i] ', 'CPU Above settings: ', 'NotificationEnabled ', $CpuAbove.NotificationEnabled, 83 | ' NotificationType ', $CpuAbove.NotificationType, ' TimeInterval ', $CpuAbove.TimeInterval, 84 | ' Percentage ', $CpuAbove.Percentage -Color Yellow, White, Yellow, Gray, Yellow, Gray, Yellow, Gray, Yellow, Gray 85 | $MonitoredDrives = Get-PulsewayLocalDiskSpace -Computer $server 86 | Write-color '[i] ', 'Drive Monitoring Count: ', $MonitoredDrives.MonitoredDrivesCount, ' NotificationEnabled ', $MonitoredDrives.NotificationEnabled -Color Yellow, White, Gray, Yellow, Gray 87 | foreach ($Drive in $MonitoredDrives.MonitoredDrives) { 88 | Write-color '[**] ', 'Drive settings: ', 'Percentage ', $Drive.Percentage, 89 | ' ID ', $Drive.ID, ' UsePercentage ', $Drive.UsePercentage, 90 | ' SizeMB ', $Drive.SizeMB -Color Yellow, White, Yellow, Gray, Yellow, Gray, Yellow, Gray, Yellow, Gray 91 | } 92 | } 93 | 94 | $MeasureTotal.Stop() 95 | Write-Color 'Time to process: ', "$($measureTotal.Elapsed)" -Color White, Yellow -------------------------------------------------------------------------------- /Examples/Example-MultipleServersServices.ps1: -------------------------------------------------------------------------------- 1 | #Install-Module PSPulsewayManager 2 | #Install-Module PSManageService 3 | Clear-Host 4 | Import-Module PSPulsewayManager -Force 5 | Import-Module PSManageService -Force 6 | 7 | $MeasureTotal = [System.Diagnostics.Stopwatch]::StartNew() # Timer Start 8 | 9 | ### Define meaningful services 10 | $ServicesOverall = @('BDESVC', 'EventLog', 'gpsvc', 'Schedule', 'Spooler', 'TermService', 'MpsSvc', 'FA_Scheduler' 11 | 'vmicheartbeat', 'vmickvpexchange', 'vmicrdv', 'vmicshutdown', 'vmictimesync', 'vmicvss', 'VSS', 'W32Time', 'WinDefend', 12 | 'WindowsAzureGuestAgent', 'WindowsAzureNetAgentSvc', 'WindowsAzureTelemetryService', 'AATPSensor', 'AATPSensorUpdater', 13 | 'WpnService', 'wuauserv', 'BITS', 'Dhcp', 'EFS', 'LanmanServer', 'LanmanWorkstation', 'RpcEptMapper', 'VaultSvc', 'RpcSs', 'netprofm', 'MSDTC', 'DPS', 'ClickToRunSvc') 14 | $ServicesIIS = @('W3SVC', 'IISADMIN', 'AppHostSvc', 'AppIDSvc', 'Appinfo', 'AppMgmt') 15 | $ServicesHA = @('Dfs', 'DFSR', 'ClusSvc') 16 | $ServicesSQL = @('SQLWriter', 'MSSQL*', 'MsDtsServer*', 'MSSQLFDLauncher*', 'SQLAgent*', 'SQLBrowser', 'SQLIaaSExtension', 'SQLSERVERAGENT', 'SQLWriter', 'SSDPSRV', 'MSDTC') 17 | $ServicesSQLControl = @('SQLTELEMETRY*', 'SSISTELEMETRY') 18 | $ServicesMonitorOverall = 'DNSCache', 'Winmgmt', 'WinRM', 'RemoteRegistry' 19 | $ServicesAD = 'ADWS', 'Netlogon', 'DNS', 'NTDS' 20 | $ServicesMonitoring = 'HealthService', 'MMAExtensionHeartbeatService', 'PC Monitor', 'RdAgent', 'AzureNetworkWatcherAgent', 'AmazonSSMAgent' 21 | $ServicesFortinet = @( 'FCEMS_ActiveDirectory', 'FCEMS_Apache', 'FCEMS_Deploy', 'FCEMS_Monitor', 'FCEMS_Server', 'FCEMS_Update', 'FCEMS_UploadServer' ) 22 | $ServicesVeeam = @('VeeamDeploySvc', 'VeeamEndpointBackupSvc') 23 | $ServicesFileServer = @('srmsvc', 'SmbHash', 'SmbWitness', 'smphost') 24 | $ServicesRDS = @('TermServLicensing', 'TScPubRPC', 'Tssdis', 'CcmExec') 25 | $ServicesService = @('SMTPSVC', 'SolarWinds SFTP Server') 26 | $ServicesNPS = @('IAS') 27 | $ServicesADFS = @('adfssrv', 'appproxyctrl', 'appproxysvc') 28 | $ServicesADConnect = @('ADSync', 'AzureADConnectHealthSyncInsights', 'AzureADConnectHealthSyncMonitor', 'WindowsAzureGuestAgent', 'WindowsAzureNetAgentSvc') 29 | $ServicesTEIIS = @('Isonet*') 30 | $ServicesSCCM = @('SMS_EXECUTIVE', 'SMS_NOTIFICATION_SERVER', 'SMS_SITE_COMPONENT_MANAGER', 'SMS_SITE_SQL_BACKUP', 'SMS_SITE_VSS_WRITER') 31 | $ServicesRRAS = @('RaMgmtSvc', 'RasMan') 32 | $ServicesBackup = @('VeeamBackupSvc', 'VeeamBrokerSvc', 'VeeamCatalogSvc', 'VeeamCloudSvc', 'VeeamDeploySvc', 'VeeamDistributionSvc', 'VeeamMountSvc', 'VeeamNFSSvc', 'VeeamTransportSvc') 33 | $ServicesATA = @('ATACenter') 34 | $ServicesCA = @('CertSvc') 35 | $ServicesPrintServer = @('Spooler') 36 | $ServicesHyperV = @('vmickvpexchange', 'vmicguestinterface', 'vmicshutdown', 'vmicheartbeat', 'vmcompute', 'vmicvmsession', 'vmicrdv', 'vmictimesync', 'vmms', 'vmicvss') 37 | ### 38 | 39 | ### prepare services for monitoring, and control 40 | 41 | $ServiceMonitor = $ServicesIIS + $ServicesHA + $ServicesSQL + $ServicesMonitorOverall + $ServicesAD + $ServicesFortinet + $ServicesVeeam + $ServicesFileServer + $ServicesRDS + $ServicesService + ` 42 | $ServicesNPS + $ServicesADFS + $ServicesADConnect + $ServicesTEIIS + $ServicesSCCM + $ServicesRRAS + ` 43 | $ServicesBackup + $ServicesATA + $ServicesCA + $ServicesPrintServer + $ServicesHyperV | Sort-Object -Unique 44 | 45 | $ServiceControlOnly = $ServicesOverall + $ServicesSQLControl + $ServicesMonitoring + $ServiceMonitor | Sort-Object -Unique 46 | 47 | $Exludes = '*-S-*', '*RD*', 'UAT*', 'PROD*', 'CLR-*', '*Clu1', '*s2d*', '*FileServer*' 48 | 49 | #$Servers = Get-ADComputer -Filter { Name -eq 'Evo1' -or Name -eq 'AD1' } -Properties OperatingSystem | Select-Object Name, DNSHostName, OperatingSystem 50 | $Servers = Get-ADComputer -Filter { OperatingSystem -like 'Windows Server*' } -Properties OperatingSystem | Select-Object Name, DNSHostName, OperatingSystem 51 | foreach ($Exclude in $Exludes) { 52 | $Servers = $Servers | Where { $_.Name -notlike $Exclude } 53 | } 54 | 55 | $Servers = $Servers | Sort-Object Name 56 | $Services = Get-PSService -Computers $Servers.Name -Services 'Pulseway' -maxRunspaces 200 #-Verbose 57 | $PulsewayUnavailable = $Services | Where { $_.Status -eq 'N/A' } 58 | $PulsewayRunning = $Services | Where { $_.Status -eq 'Running' } 59 | 60 | Write-Color 'Servers to process: ', $Servers.Count, ' servers running: ', $PulsewayRunning.Count, ' servers unavailable: ', $PulsewayUnavailable.Count -Color White, Yellow, White, Yellow, White, Yellow 61 | Write-Color 'Pulseway is running: ', $PulsewayRunning.Count -Color White, Green 62 | #$PulsewayRunning | Format-Table -AutoSize 63 | Write-Color 'Pulseway is unavailable: ', $PulsewayUnavailable.Count -Color White, Red 64 | #$PulsewayUnavailable | Format-Table -AutoSize 65 | 66 | $ServerServicesAll = Get-PSService -Computers $PulsewayRunning.Computer -maxRunspaces 200 #-Verbose 67 | 68 | foreach ($server in $PulsewayRunning.Computer) { 69 | Write-Color '[start]', ' Processing server: ', $Server, ' for ', 'Services' -Color Green, White, Yellow, White, Yellow 70 | 71 | $ServicesToProcessAll = $ServerServicesAll | Where { $_.Computer -eq $server } 72 | $ServicesToProcessRunning = $ServerServicesAll | Where { $_.Computer -eq $server -and $_.Status -eq 'Running' -and $_.StartType -eq 'Automatic' } 73 | 74 | $Green = foreach ($service in $ServicesToProcessAll.name) { 75 | foreach ($service2 in $ServiceControlOnly) { 76 | if ($service -like $service2) { 77 | Write-Output $service 78 | } 79 | } 80 | } 81 | 82 | $Yellow = foreach ($service in $ServicesToProcessRunning.name) { 83 | foreach ($service2 in $ServiceMonitor) { 84 | if ($service -like $service2) { 85 | Write-Output $service 86 | } 87 | } 88 | } 89 | 90 | Write-Color '[**]' , ' Enabling those services for control ' , ([string] $Green) -Color Yellow, White, Green 91 | Write-Color '[**]' , ' Enabling those services for monitoring ' , ([string] $Yellow) -Color Yellow, White, Green 92 | Set-PulsewayMonitoredServices -Computer $Server -Services $Green -ServicesToMonitor $Yellow -SendNotificationOnServiceStop Enabled -PrioritySendNotificationOnServiceStop Critical #-Verbose 93 | 94 | } 95 | 96 | $MeasureTotal.Stop() 97 | Write-Color 'Time to process: ', "$($measureTotal.Elapsed)" -Color White, Yellow 98 | -------------------------------------------------------------------------------- /Examples/Example-PanelAccountPageSettings.ps1: -------------------------------------------------------------------------------- 1 | Clear-Host 2 | Import-Module PSPulsewayManager -Force 3 | 4 | ### Tests - Account Page ### 5 | Get-PulsewayMaintenanceMode 6 | Set-PulsewayMaintenanceMode -Toggle $false -Verbose 7 | Get-PulsewayGroupName 8 | Set-PulsewayGroupName -GroupName 'EVOTEC' -Verbose 9 | Get-PulsewayComputerName 10 | Set-PulsewayComputerName -NewComputerName 'EVO1' -Verbose 11 | 12 | ### Set settings remotly... 13 | 14 | $Computer = 'AD1' 15 | Get-PulsewayMaintenanceMode -Computer $Computer 16 | Set-PulsewayMaintenanceMode -Computer $Computer -Toggle $false -Verbose 17 | Get-PulsewayGroupName -Computer $Computer 18 | Set-PulsewayGroupName -Computer $Computer -GroupName 'EVOTEC' -Verbose 19 | Get-PulsewayComputerName -Computer $Computer 20 | Set-PulsewayComputerName -Computer $Computer -NewComputerName 'AD1' -Verbose -------------------------------------------------------------------------------- /Examples/Example-PanelNotificationsPefromance.ps1: -------------------------------------------------------------------------------- 1 | Clear-Host 2 | Import-Module PSPulsewayManager -Force 3 | Import-Module PSWriteColor 4 | 5 | ### Tests - Notifications Performance Page ### 6 | 7 | Write-Color '[i] Get ', 'CPU usage below', ' settings' -Color Yellow, Green, Yellow 8 | Get-PulsewayCPUBelow 9 | Write-Color '[i] Get ', 'CPU usage above', ' settings' -Color Yellow, Green, Yellow 10 | Get-PulsewayCPUAbove 11 | Write-Color '[i] Get ', 'Memory', ' settings' -Color Yellow, Green, Yellow 12 | Get-PulsewayMemoryLow 13 | Write-Color '[i] Get ', 'Port Closed', ' settings' -Color Yellow, Green, Yellow 14 | Get-PulsewayMonitoredPortClosed 15 | 16 | Set-PulsewayCPUAbove -CPUUsagePercentage 25 -CPUUsageTimeInterval 20 -PrioritySendNotificationOnCPUUsage Elevated -SendNotificationOnCPUUsage Enabled -Verbose 17 | Set-PulsewayCPUBelow -BelowCPUUsagePercentage 2 -BelowCPUUsageTimeInterval 20 -PrioritySendNotificationOnBelowCPUUsage Elevated -SendNotificationOnBelowCPUUsage Disabled -Verbose 18 | Set-PulsewayMemoryLow -LowMemoryPercentage 10 -LowMemoryTimeInterval 15 -PrioritySendNotificationOnLowMemory Critical -SendNotificationOnLowMemory Enabled -Verbose 19 | Set-PulsewayMonitoredPortClosed -PortInterval 2 -PrioritySendNotificationOnPortNotAccessible Critical -SendNotificationOnPortNotAccessible Enabled -Verbose 20 | -------------------------------------------------------------------------------- /Examples/Example-PanelNotificationsServices.ps1: -------------------------------------------------------------------------------- 1 | Clear-Host 2 | Import-Module PSPulsewayManager -Force 3 | Import-Module PSManageService #-Force 4 | 5 | Write-Color '[i] Get ', 'Services', ' settings' -Color Yellow, Green, Yellow 6 | $Services = Get-PulsewayMonitoredServices 7 | $Services 8 | Write-Color '[i] Get ', 'Services', ' monitored' -Color Yellow, Green, Yellow 9 | $Services.ServicesMonitored 10 | Write-Color '[i] Get ', 'Services', ' excluded from monitoring' -Color Yellow, Green, Yellow 11 | $Services.ServicesExcluded 12 | Write-Color '[i] Get ', 'Services', ' controled (all)' -Color Yellow, Green, Yellow 13 | $Services.ServicesControled 14 | 15 | #$servicesToMonitor = Get-PSService -Computers 'EVO1' 16 | #$servicesToMonitor = $servicesToMonitor | Where { $_.Status -eq 'Running' -and $_.StartType -eq 'Automatic' } 17 | #$servicesToMonitor | ft -a 18 | 19 | $MonitorServiceControlled = @('BITS', 'IISADMIN', 'Audiosrv') 20 | $MonitorServiceNotification = @('IISADMIN') 21 | 22 | Set-PulsewayMonitoredServices -Services $MonitorServiceControlled -servicesToMonitor $MonitorServiceNotification -SendNotificationOnServiceStop Enabled -PrioritySendNotificationOnServiceStop Low 23 | -------------------------------------------------------------------------------- /Examples/Example-PanelNotificationsStorage.ps1: -------------------------------------------------------------------------------- 1 | Clear-Host 2 | Import-Module PSPulsewayManager -Force 3 | Import-Module PSWriteColor 4 | 5 | $Computer = 'AD1' 6 | 7 | Write-Color 'Get ', 'Low Disk Space' -Color White, Yellow 8 | $Drives = Get-PulsewayLocalDiskSpace -Computer $Computer -Verbose 9 | $Drives 10 | Write-Color 'List ', ' drives separatly' -Color White, Yellow -LinesAfter 1 11 | $Drives.MonitoredDrives 12 | 13 | ## Find all drives for computer/server 14 | $FindDrives = Get-Drive -Computer $Computer 15 | $FindDrives 16 | $ListDrives = @() 17 | # Set the settings for all drives for particular computer/server (Elevated) 18 | $DrivesElevated = Set-DriveSettings -Drive $FindDrives -Percentage 10 -Priority Elevated -SizeMB 20000 -UsePercentage No 19 | # Repeat process for same drives but make it critical 20 | $DrivesCritical = Set-DriveSettings -Drive $FindDrives -Percentage 10 -Priority Critical -SizeMB 10000 -UsePercentage No 21 | 22 | $ListDrives += $DrivesElevated 23 | $ListDrives += $DrivesCritical 24 | 25 | #Set-PulsewayLocalDiskSpace -Computer $Computer -Drives $ListDrives -SendNotificationOnLowHDDSpace Enabled -Verbose -------------------------------------------------------------------------------- /Examples/Example-PulsewayCheck.ps1: -------------------------------------------------------------------------------- 1 | Clear-Host 2 | Import-Module PSPulsewayManager -Force 3 | Import-Module PSManageService -Force 4 | Import-Module PSWriteColor 5 | 6 | # built in but accepts only one... 7 | Get-PulsewayStatus -Computer 'AD1' 8 | 9 | # useful if you don't want to wait for results 10 | $Computers = 'AD1', 'EVO1' 11 | Get-PSService -Computers $Computers -Services 'Pulseway' -------------------------------------------------------------------------------- /PSPulsewayManager.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'PSPulsewayManager' 3 | # 4 | # Generated by: Przemyslaw Klys 5 | # 6 | # Generated on: 08.06.2018 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = 'PSPulsewayManager.psm1' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '0.6' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = '237574c7-8e06-4c86-b012-741f4bfd6aff' 22 | 23 | # Author of this module 24 | Author = 'Przemyslaw Klys' 25 | 26 | # Company or vendor of this module 27 | CompanyName = 'Evotec' 28 | 29 | # Copyright statement for this module 30 | Copyright = 'Evotec (c) 2018. All rights reserved.' 31 | 32 | # Description of the functionality provided by this module 33 | Description = 'This powershell module allows easy management and configuration of Pulseway Manager.' 34 | 35 | # Minimum version of the Windows PowerShell engine required by this module 36 | # PowerShellVersion = '' 37 | 38 | # Name of the Windows PowerShell host required by this module 39 | # PowerShellHostName = '' 40 | 41 | # Minimum version of the Windows PowerShell host required by this module 42 | # PowerShellHostVersion = '' 43 | 44 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 45 | # DotNetFrameworkVersion = '' 46 | 47 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 48 | # CLRVersion = '' 49 | 50 | # Processor architecture (None, X86, Amd64) required by this module 51 | # ProcessorArchitecture = '' 52 | 53 | # Modules that must be imported into the global environment prior to importing this module 54 | # RequiredModules = @() 55 | RequiredModules = @('PSManageService', 'PSWriteColor') 56 | 57 | # Assemblies that must be loaded prior to importing this module 58 | # RequiredAssemblies = @() 59 | 60 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 61 | ScriptsToProcess = @('Enums\Enums.ps1') 62 | 63 | # Type files (.ps1xml) to be loaded when importing this module 64 | # TypesToProcess = @() 65 | 66 | # Format files (.ps1xml) to be loaded when importing this module 67 | # FormatsToProcess = @() 68 | 69 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 70 | # NestedModules = @() 71 | 72 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 73 | FunctionsToExport = '*' 74 | 75 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 76 | CmdletsToExport = @() 77 | 78 | # Variables to export from this module 79 | VariablesToExport = @() 80 | 81 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 82 | AliasesToExport = @() 83 | 84 | # DSC resources to export from this module 85 | # DscResourcesToExport = @() 86 | 87 | # List of all modules packaged with this module 88 | # ModuleList = @() 89 | 90 | # List of all files packaged with this module 91 | #FileList = 'PSPulsewayManager.psm1', 'PSPulsewayManager.psd1' 92 | 93 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 94 | PrivateData = @{ 95 | 96 | PSData = @{ 97 | 98 | # Tags applied to this module. These help with module discovery in online galleries. 99 | Tags = @('pulseway', 'powershell') 100 | 101 | # A URL to the license for this module. 102 | # LicenseUri = '' 103 | 104 | # A URL to the main website for this project. 105 | ProjectUri = 'https://github.com/EvotecIT/PSPulsewayManager' 106 | 107 | # A URL to an icon representing this module. 108 | # IconUri = '' 109 | 110 | # ReleaseNotes of this module 111 | # ReleaseNotes = '' 112 | 113 | } # End of PSData hashtable 114 | 115 | } # End of PrivateData hashtable 116 | 117 | # HelpInfo URI of this module 118 | HelpInfoURI = 'https://github.com/EvotecIT/PSPulsewayManager' 119 | 120 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 121 | # DefaultCommandPrefix = '' 122 | 123 | } 124 | -------------------------------------------------------------------------------- /PSPulsewayManager.psm1: -------------------------------------------------------------------------------- 1 | #Get public and private function definition files. 2 | $Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue ) 3 | $Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue ) 4 | 5 | #Dot source the files 6 | Foreach ($import in @($Public + $Private)) { 7 | Try { 8 | . $import.fullname 9 | } Catch { 10 | Write-Error -Message "Failed to import function $($import.fullname): $_" 11 | } 12 | } 13 | Export-ModuleMember -Function '*' -------------------------------------------------------------------------------- /Private/PSRunspace.ps1: -------------------------------------------------------------------------------- 1 | function New-Runspace { 2 | param ( 3 | [int] $minRunspaces = 1, 4 | [int] $maxRunspaces = [int]$env:NUMBER_OF_PROCESSORS + 1 5 | ) 6 | $RunspacePool = [RunspaceFactory]::CreateRunspacePool($minRunspaces, $maxRunspaces) 7 | $RunspacePool.ApartmentState = "MTA" 8 | $RunspacePool.Open() 9 | return $RunspacePool 10 | } 11 | function Start-Runspace { 12 | param ( 13 | $ScriptBlock, 14 | [hashtable] $Parameters, 15 | [System.Management.Automation.Runspaces.RunspacePool] $RunspacePool 16 | ) 17 | $runspace = [PowerShell]::Create() 18 | $null = $runspace.AddScript($ScriptBlock) 19 | $null = $runspace.AddParameters($Parameters) 20 | $runspace.RunspacePool = $RunspacePool 21 | return [PSCustomObject]@{ Pipe = $runspace; Status = $runspace.BeginInvoke() } 22 | } 23 | 24 | function Stop-Runspace { 25 | param( 26 | $Runspaces, 27 | [string] $FunctionName, 28 | [System.Management.Automation.Runspaces.RunspacePool] $RunspacePool 29 | ) 30 | $List = @() 31 | while ($Runspaces.Status -ne $null) { 32 | $completed = $runspaces | Where-Object { $_.Status.IsCompleted -eq $true } 33 | foreach ($runspace in $completed) { 34 | foreach ($e in $($runspace.Pipe.Streams.Error)) { 35 | Write-Verbose "$FunctionName - Error from runspace: $e" 36 | } 37 | foreach ($v in $($runspace.Pipe.Streams.Verbose)) { 38 | Write-Verbose "$FunctionName - Verbose from runspace: $v" 39 | } 40 | $List += $runspace.Pipe.EndInvoke($runspace.Status) 41 | $runspace.Status = $null 42 | } 43 | } 44 | $RunspacePool.Close() 45 | $RunspacePool.Dispose() 46 | return $List 47 | } -------------------------------------------------------------------------------- /Private/SupportFunctions.ps1: -------------------------------------------------------------------------------- 1 | function Set-RegistryRemote { 2 | [cmdletbinding()] 3 | param( 4 | [string[]]$Computer, 5 | [string] $RegistryPath, 6 | [string[]]$RegistryKey, 7 | [string[]]$Value, 8 | [parameter(Mandatory = $False)][Switch]$PassThru 9 | ) 10 | 11 | $ScriptBlock = { 12 | #[cmdletbinding()] 13 | param( 14 | [string] $RegistryPath, 15 | [string[]] $RegistryKey, 16 | [string[]] $Value, 17 | [bool]$PassThru 18 | ) 19 | $VerbosePreference = $Using:VerbosePreference 20 | $List = New-Object System.Collections.ArrayList 21 | 22 | for ($i = 0; $i -lt $RegistryKey.Count; $i++) { 23 | Write-Verbose "REG WRITE: $RegistryPath REGKEY: $($RegistryKey[$i]) REGVALUE: $($Value[$i])" # PassThru: $PassThru" 24 | $Setting = Set-ItemProperty -Path $RegistryPath -Name $RegistryKey[$i] -Value $Value[$i] -PassThru:$PassThru 25 | if ($PassThru -eq $true) { $List.Add($Setting) > $null } 26 | } 27 | return $List 28 | } 29 | 30 | $ListComputers = New-Object System.Collections.ArrayList 31 | foreach ($Comp in $Computer) { 32 | $Return = Invoke-Command -ComputerName $Computer -ScriptBlock $ScriptBlock -ArgumentList $RegistryPath, $RegistryKey, $Value, $PassThru 33 | if ($PassThru -eq $true) { $ListComputers.Add($Return) > $null } 34 | } 35 | return $ListComputers 36 | } 37 | 38 | function Get-RegistryRemoteList { 39 | param( 40 | [string[]]$Computer = $Env:COMPUTERNAME, 41 | [string]$RegistryPath 42 | ) 43 | $ScriptBlock = { 44 | [cmdletbinding()] 45 | param( 46 | [string]$RegistryPath 47 | ) 48 | $VerbosePreference = $Using:VerbosePreference 49 | $Setting = Get-ItemProperty -Path $RegistryPath 50 | return $Setting 51 | } 52 | 53 | $ListComputers = New-Object System.Collections.ArrayList 54 | foreach ($Comp in $Computer) { 55 | $Return = Invoke-Command -ComputerName $Comp -ScriptBlock $ScriptBlock -ArgumentList $RegistryPath 56 | $ListComputers.Add($Return) > $null 57 | } 58 | return $ListComputers 59 | } 60 | 61 | function Get-RegistryRemote { 62 | [cmdletbinding()] 63 | param( 64 | [string[]]$Computer = $Env:COMPUTERNAME, 65 | [string]$RegistryPath, 66 | [string[]]$RegistryKey 67 | ) 68 | 69 | 70 | $ScriptBlock = { 71 | [cmdletbinding()] 72 | param( 73 | [string]$RegistryPath, 74 | [string[]]$RegistryKey 75 | ) 76 | $VerbosePreference = $Using:VerbosePreference 77 | $List = New-Object System.Collections.ArrayList 78 | 79 | #Write-Verbose "REG READ: $RegistryPath REGKEY: $($RegistryKey)" 80 | 81 | for ($i = 0; $i -lt $RegistryKey.Count; $i++) { 82 | $RegKey = $RegistryKey[$i] 83 | $Setting = Get-ItemProperty -Path $RegistryPath -Name $RegKey 84 | Write-Verbose "REG READ: $RegistryPath REGKEY: $RegKey REG VALUE: $($Setting.$RegKey)" 85 | $List.Add($Setting.$RegKey) > $null 86 | } 87 | return $List 88 | } 89 | $ListComputers = New-Object System.Collections.ArrayList 90 | foreach ($Comp in $Computer) { 91 | $Return = Invoke-Command -ComputerName $Comp -ScriptBlock $ScriptBlock -ArgumentList $RegistryPath, $RegistryKey 92 | $ListComputers.Add($Return) > $null 93 | } 94 | return $ListComputers 95 | } 96 | 97 | function Get-ObjectCount($Object) { 98 | return $($Object | Measure-Object).Count 99 | } -------------------------------------------------------------------------------- /Public/PulsewayAccount.ps1: -------------------------------------------------------------------------------- 1 | # Account - Maintenance Mode 2 | function Get-PulsewayMaintenanceMode { 3 | [cmdletbinding()] 4 | param( 5 | $Computer = $Env:COMPUTERNAME 6 | ) 7 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 8 | $RegistryKey = 'MaintenanceMode' 9 | 10 | Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey 11 | } 12 | function Set-PulsewayMaintenanceMode { 13 | [cmdletbinding()] 14 | param( 15 | [string[]] $Computer = $Env:COMPUTERNAME, 16 | [System.Nullable[bool]] $Toggle = $null 17 | ) 18 | if ($Toggle -eq $null) { return 'Error: Not set. Not enough parameters!' } 19 | 20 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 21 | $RegistryKey = 'MaintenanceMode' 22 | 23 | if ($Toggle) { $Value = 1 } else { $Value = 0 } 24 | 25 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey -Value $Value 26 | } 27 | 28 | # Account - Dedicated Server 29 | function Set-PulsewaCustomServerAddress { 30 | [cmdletbinding()] 31 | param( 32 | [string[]] $Computer = $Env:COMPUTERNAME, 33 | [string] $CustomServerAddress = '' 34 | ) 35 | if ($CustomServerAddress -eq '') { return 'Error: Not set. Not enough parameters!' } 36 | 37 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 38 | $RegistryKey = 'CustomServerAddress' 39 | 40 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey -Value $CustomServerAddress 41 | } 42 | function Get-PulsewaCustomServerAddress { 43 | [cmdletbinding()] 44 | param( 45 | [string[]] $Computer = $Env:COMPUTERNAME 46 | 47 | ) 48 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 49 | $RegistryKey = 'CustomServerAddress' 50 | 51 | Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey 52 | } 53 | 54 | # Account - Computer Information 55 | 56 | function Set-PulsewayGroupName { 57 | [cmdletbinding()] 58 | param( 59 | [string[]] $Computer = $Env:COMPUTERNAME, 60 | [string] $GroupName = '' 61 | ) 62 | if ($GroupName -eq '') { return 'Error: Not set. Not enough parameters!' } 63 | 64 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 65 | $RegistryKey = 'GroupName' 66 | 67 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey -Value $GroupName 68 | } 69 | function Get-PulsewayGroupName { 70 | [cmdletbinding()] 71 | param( 72 | [string[]] $Computer = $Env:COMPUTERNAME 73 | 74 | ) 75 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 76 | $RegistryKey = 'GroupName' 77 | 78 | Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey 79 | } 80 | function Get-PulsewayComputerName { 81 | [cmdletbinding()] 82 | param( 83 | [string[]] $Computer = $Env:COMPUTERNAME 84 | 85 | ) 86 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 87 | $RegistryKey = 'ComputerName' 88 | 89 | Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey 90 | } 91 | 92 | function Set-PulsewayComputerName { 93 | [cmdletbinding()] 94 | param( 95 | [string[]] $Computer = $Env:COMPUTERNAME, 96 | [string] $NewComputerName = '' 97 | ) 98 | if ($NewComputerName -eq '') { return 'Error: Not set. Not enough parameters!' } 99 | 100 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 101 | $RegistryKey = 'ComputerName' 102 | 103 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey -Value $NewComputerName 104 | } -------------------------------------------------------------------------------- /Public/PulsewayManager.ps1: -------------------------------------------------------------------------------- 1 | function Get-PulsewayStatus { 2 | param( 3 | [string] $Computer = $ENV:COMPUTERNAME 4 | ) 5 | $Service = Get-PSService -Computers $Computer -Services 'Pulseway' 6 | if ($Service.Status -eq 'Running') { 7 | return [PulsewayStatus]::Running 8 | } elseif ($Service.Stuats -eq 'N/A') { 9 | return [PulsewayStatus]::NotAvailable 10 | } else { 11 | return [PulsewayStatus]::NotRunning 12 | } 13 | } -------------------------------------------------------------------------------- /Public/PulsewayNotificationsPerformance.ps1: -------------------------------------------------------------------------------- 1 | function Get-PulsewayCPUBelow { 2 | [cmdletbinding()] 3 | param( 4 | [string] $Computer = $Env:COMPUTERNAME 5 | ) 6 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 7 | $RegistryKey1 = 'BelowCPUUsagePercentage' # 1 to 99 8 | $RegistryKey2 = 'BelowCPUUsageTimeInterval' # 1 to 120 9 | $RegistryKey3 = 'PrioritySendNotificationOnBelowCPUUsage' 10 | $RegistryKey4 = 'SendNotificationOnBelowCPUUsage' # 1 or 0 11 | 12 | $ReadRegistry = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 13 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3, $RegistryKey4 14 | 15 | $Percentage = $ReadRegistry[0] 16 | $TimeInterval = $ReadRegistry[1] 17 | $NotificationType = $ReadRegistry[2] 18 | $NotificationEnabled = $ReadRegistry[3] 19 | 20 | $Return = [ordered] @{ 21 | Name = 'CPU Below' 22 | Percentage = $Percentage 23 | TimeInterval = $TimeInterval 24 | NotificationType = $NotificationType -As [NotificationType] 25 | NotificationEnabled = $NotificationEnabled -As [NotificationStatus] 26 | } 27 | return $Return 28 | } 29 | 30 | function Set-PulsewayCPUBelow { 31 | [cmdletbinding()] 32 | param( 33 | [string] $Computer = $Env:COMPUTERNAME, 34 | [int] $BelowCPUUsagePercentage = 10, 35 | [int] $BelowCPUUsageTimeInterval = 1, 36 | [System.Nullable[NotificationType]] $PrioritySendNotificationOnBelowCPUUsage = $null, 37 | [System.Nullable[NotificationStatus]] $SendNotificationOnBelowCPUUsage = $null 38 | ) 39 | if ($PrioritySendNotificationOnBelowCPUUsage -eq $null -or $SendNotificationOnBelowCPUUsage -eq $null) { 40 | return 'Error: Not set. Not enough parameters!' 41 | } 42 | 43 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 44 | $RegistryKey1 = 'BelowCPUUsagePercentage' # 1 to 99 45 | $RegistryKey2 = 'BelowCPUUsageTimeInterval' # 1 to 120 46 | $RegistryKey3 = 'PrioritySendNotificationOnBelowCPUUsage' 47 | $RegistryKey4 = 'SendNotificationOnBelowCPUUsage' # 1 or 0 48 | 49 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 50 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3, $RegistryKey4 ` 51 | -Value $BelowCPUUsagePercentage, $BelowCPUUsageTimeInterval, ($PrioritySendNotificationOnBelowCPUUsage -As [Int]), ($SendNotificationOnBelowCPUUsage -As [Int]) 52 | } 53 | 54 | function Get-PulsewayCPUAbove { 55 | [cmdletbinding()] 56 | param( 57 | [string] $Computer = $Env:COMPUTERNAME 58 | ) 59 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 60 | $RegistryKey1 = 'CPUUsagePercentage' # 1 to 99 61 | $RegistryKey2 = 'CPUUsageTimeInterval' # 1 to 120 62 | $RegistryKey3 = 'PrioritySendNotificationOnCPUUsage' 63 | $RegistryKey4 = 'SendNotificationOnCPUUsage' # 1 or 0 64 | 65 | $ReadRegistry = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 66 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3, $RegistryKey4 67 | 68 | $Percentage = $ReadRegistry[0] 69 | $TimeInterval = $ReadRegistry[1] 70 | $NotificationType = $ReadRegistry[2] 71 | $NotificationEnabled = $ReadRegistry[3] 72 | 73 | $Return = [ordered] @{ 74 | Name = 'CPU Above' 75 | Percentage = $Percentage 76 | TimeInterval = $TimeInterval 77 | NotificationType = $NotificationType -As [NotificationType] 78 | NotificationEnabled = $NotificationEnabled -As [NotificationStatus] 79 | } 80 | return $Return 81 | } 82 | 83 | function Set-PulsewayCPUAbove { 84 | [cmdletbinding()] 85 | param( 86 | [string] $Computer = $Env:COMPUTERNAME, 87 | [int] $CPUUsagePercentage = 10, 88 | [int] $CPUUsageTimeInterval = 1, 89 | [System.Nullable[NotificationType]] $PrioritySendNotificationOnCPUUsage = $null, 90 | [System.Nullable[NotificationStatus]] $SendNotificationOnCPUUsage = $null 91 | ) 92 | if ($PrioritySendNotificationOnCPUUsage -eq $null -or $SendNotificationOnCPUUsage -eq $null) { 93 | return 'Error: Not set. Not enough parameters!' 94 | } 95 | 96 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 97 | $RegistryKey1 = 'CPUUsagePercentage' # 1 to 99 98 | $RegistryKey2 = 'CPUUsageTimeInterval' # 1 to 120 99 | $RegistryKey3 = 'PrioritySendNotificationOnCPUUsage' 100 | $RegistryKey4 = 'SendNotificationOnCPUUsage' # 1 or 0 101 | 102 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 103 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3, $RegistryKey4 ` 104 | -Value $CPUUsagePercentage, $CPUUsageTimeInterval, ($PrioritySendNotificationOnCPUUsage -As [Int]), ($SendNotificationOnCPUUsage -As [Int]) 105 | } 106 | 107 | function Get-PulsewayMemoryLow { 108 | [cmdletbinding()] 109 | param( 110 | [string] $Computer = $Env:COMPUTERNAME 111 | ) 112 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 113 | $RegistryKey1 = 'LowMemoryPercentage' # 1 to 99 114 | $RegistryKey2 = 'LowMemoryTimeInterval' # 1 to 120 115 | $RegistryKey3 = 'PrioritySendNotificationOnLowMemory' 116 | $RegistryKey4 = 'SendNotificationOnLowMemory' # 1 or 0 117 | 118 | $ReadRegistry = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 119 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3, $RegistryKey4 120 | 121 | $Percentage = $ReadRegistry[0] 122 | $TimeInterval = $ReadRegistry[1] 123 | $NotificationType = $ReadRegistry[2] 124 | $NotificationEnabled = $ReadRegistry[3] 125 | 126 | $Return = [ordered] @{ 127 | Name = 'Low Memory' 128 | Percentage = $Percentage 129 | TimeInterval = $TimeInterval 130 | NotificationType = $NotificationType -As [NotificationType] 131 | NotificationEnabled = $NotificationEnabled -As [NotificationStatus] 132 | } 133 | return $Return 134 | } 135 | 136 | function Set-PulsewayMemoryLow { 137 | [cmdletbinding()] 138 | param( 139 | [string] $Computer = $Env:COMPUTERNAME, 140 | [int] $LowMemoryPercentage = 10, 141 | [int] $LowMemoryTimeInterval = 1, 142 | [System.Nullable[NotificationType]] $PrioritySendNotificationOnLowMemory = $null, 143 | [System.Nullable[NotificationStatus]] $SendNotificationOnLowMemory = $null 144 | ) 145 | if ($PrioritySendNotificationOnLowMemory -eq $null -or $SendNotificationOnLowMemory -eq $null) { 146 | return 'Error: Not set. Not enough parameters!' 147 | } 148 | 149 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 150 | $RegistryKey1 = 'LowMemoryPercentage' # 1 to 99 151 | $RegistryKey2 = 'LowMemoryTimeInterval' # 1 to 120 152 | $RegistryKey3 = 'PrioritySendNotificationOnLowMemory' 153 | $RegistryKey4 = 'SendNotificationOnLowMemory' # 1 or 0 154 | 155 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 156 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3, $RegistryKey4 ` 157 | -Value $LowMemoryPercentage, $LowMemoryTimeInterval, ($PrioritySendNotificationOnLowMemory -As [Int]), ($SendNotificationOnLowMemory -As [Int]) 158 | } 159 | 160 | 161 | function Get-PulsewayMonitoredPortClosed { 162 | [cmdletbinding()] 163 | param( 164 | [string] $Computer = $Env:COMPUTERNAME 165 | ) 166 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 167 | $RegistryKey1 = 'SendNotificationOnPortNotAccessible' # 1 to 99 168 | $RegistryKey2 = 'PortInterval' # 1 to 120 169 | $RegistryKey3 = 'PrioritySendNotificationOnPortNotAccessible' 170 | 171 | $ReadRegistry = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 172 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3 173 | 174 | $NotificationEnabled = $ReadRegistry[0] 175 | $TimeInterval = $ReadRegistry[1] 176 | $NotificationType = $ReadRegistry[2] 177 | 178 | $Return = [ordered] @{ 179 | Name = 'Monitored Port Closed' 180 | TimeInterval = $TimeInterval 181 | NotificationType = $NotificationType -As [NotificationType] 182 | NotificationEnabled = $NotificationEnabled -As [NotificationStatus] 183 | } 184 | return $Return 185 | } 186 | 187 | function Set-PulsewayMonitoredPortClosed { 188 | [cmdletbinding()] 189 | param( 190 | [string] $Computer = $Env:COMPUTERNAME, 191 | [int] $PortInterval = 10, 192 | [System.Nullable[NotificationType]] $PrioritySendNotificationOnPortNotAccessible = $null, 193 | [System.Nullable[NotificationStatus]] $SendNotificationOnPortNotAccessible = $null 194 | ) 195 | if ($PrioritySendNotificationOnPortNotAccessible -eq $null -or $SendNotificationOnPortNotAccessible -eq $null) { 196 | return 'Error: Not set. Not enough parameters!' 197 | } 198 | 199 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 200 | $RegistryKey1 = 'PortInterval' 201 | $RegistryKey2 = 'PrioritySendNotificationOnPortNotAccessible' 202 | $RegistryKey3 = 'SendNotificationOnPortNotAccessible' 203 | 204 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 205 | -RegistryKey $RegistryKey1, $RegistryKey2, $RegistryKey3 ` 206 | -Value $PortInterval, ($PrioritySendNotificationOnPortNotAccessible -As [Int]), ($SendNotificationOnPortNotAccessible -As [Int]) 207 | } -------------------------------------------------------------------------------- /Public/PulsewayNotificationsServices.ps1: -------------------------------------------------------------------------------- 1 | function Get-PulsewayMonitoredServices { 2 | [cmdletbinding()] 3 | param( 4 | [string] $Computer = $Env:COMPUTERNAME 5 | ) 6 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 7 | $RegistryKey1 = 'SendNotificationOnServiceStop' 8 | $RegistryKey2 = 'PrioritySendNotificationOnServiceStop' 9 | 10 | $RegistryPathSub1 = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor\Services' 11 | $RegistryKeySub1 = 'Count' 12 | 13 | $RegistryPathSub2 = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor\ServicesExcludedFromNotifications' 14 | $RegistryKeySub2 = 'Count' 15 | 16 | $ReadRegistry = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey1, $RegistryKey2 17 | $NotificationEnabled = $ReadRegistry[0] 18 | $NotificationType = $ReadRegistry[1] 19 | 20 | $ReadRegistrySub1 = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub1 -RegistryKey $RegistryKeySub1 21 | $ServicesCount = $ReadRegistrySub1 22 | 23 | $ReadRegistrySub2 = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub2 -RegistryKey $RegistryKeySub2 24 | $ServicesExcludedCount = $ReadRegistrySub2 25 | 26 | $ListControlled = New-Object System.Collections.ArrayList 27 | 28 | $Services = Get-RegistryRemoteList -Computer $Computer -RegistryPath $RegistryPathSub1 29 | for ($i = 0; $i -lt $Services.Count; $i++) { 30 | $Service = "Service$i" 31 | $ListControlled.Add($Services.$Service) > $null 32 | } 33 | 34 | $ListExcluded = New-Object System.Collections.ArrayList 35 | $Services = Get-RegistryRemoteList -Computer $Computer -RegistryPath $RegistryPathSub2 36 | for ($i = 0; $i -lt $Services.Count; $i++) { 37 | $Service = "Service$i" 38 | $ListExcluded.Add($Services.$Service) > $null 39 | } 40 | 41 | $ListMonitored = Compare-Object -ReferenceObject $ListControlled -DifferenceObject $ListExcluded -PassThru 42 | 43 | $Return = [ordered] @{ 44 | Name = 'Services' 45 | ComputerName = $Computer 46 | CountServicesControlled = $ServicesCount 47 | CountServicesExcluded = $ServicesExcludedCount 48 | CountServicesMonitored = $ListMonitored.Count 49 | NotificationType = $NotificationType -As [NotificationType] 50 | NotificationEnabled = $NotificationEnabled -As [NotificationStatus] 51 | ServicesControled = $ListControlled 52 | ServicesExcluded = $ListExcluded 53 | ServicesMonitored = $ListMonitored 54 | } 55 | return $Return 56 | } 57 | 58 | function Set-PulsewayMonitoredServices { 59 | [cmdletbinding()] 60 | param( 61 | [string] $Computer = $Env:COMPUTERNAME, 62 | [array] $Services, 63 | [array] $ServicesToMonitor, 64 | [NotificationStatus] $SendNotificationOnServiceStop, 65 | [NotificationType] $PrioritySendNotificationOnServiceStop, 66 | [parameter(Mandatory = $False)][Switch]$PassThru 67 | ) 68 | Write-Verbose 'Set-PulsewayMonitoredServices - GetType: ' 69 | 70 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 71 | $RegistryKey1 = 'SendNotificationOnServiceStop' 72 | $RegistryKey2 = 'PrioritySendNotificationOnServiceStop' 73 | 74 | $RegistryPathSub1 = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor\Services' 75 | $RegistryKeySub1 = 'Count' 76 | 77 | $RegistryPathSub2 = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor\ServicesExcludedFromNotifications' 78 | $RegistryKeySub2 = 'Count' 79 | 80 | $Count = Get-ObjectCount $Services 81 | 82 | $ServicesExcluded = Compare-Object -ReferenceObject $Services -DifferenceObject $ServicesToMonitor -PassThru 83 | $CountExcluded = Get-ObjectCount $ServicesExcluded 84 | 85 | # Enable/disable notification 86 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 87 | -RegistryKey $RegistryKey1, $RegistryKey2 ` 88 | -Value ($SendNotificationOnServiceStop -As [int]), ($PrioritySendNotificationOnServiceStop -As [Int]) ` 89 | -PassThru:$PassThru 90 | 91 | # Count number of services 92 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub1 ` 93 | -RegistryKey $RegistryKeySub1 ` 94 | -Value $Count -PassThru:$PassThru 95 | # Count number of services excluded 96 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub2 ` 97 | -RegistryKey $RegistryKeySub2 ` 98 | -Value $CountExcluded -PassThru:$PassThru 99 | 100 | $ListServicesNameA = @() 101 | for ($i = 0; $i -le $Services.Count; $i++) { 102 | $ListServicesNameA += "Service$i" 103 | } 104 | $ListServicesNameB = @() 105 | for ($i = 0; $i -le $ServicesExcluded.Count; $i++) { 106 | $ListServicesNameB += "Service$i" 107 | } 108 | 109 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub1 ` 110 | -RegistryKey $ListServicesNameA ` 111 | -Value $Services ` 112 | -PassThru:$PassThru 113 | 114 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub2 ` 115 | -RegistryKey $ListServicesNameB ` 116 | -Value $ServicesExcluded ` 117 | -PassThru:$PassThru 118 | 119 | } -------------------------------------------------------------------------------- /Public/PulsewayNotificationsStorage.ps1: -------------------------------------------------------------------------------- 1 | function Get-PulsewayLocalDiskSpace { 2 | [cmdletbinding()] 3 | param( 4 | [string] $Computer = $Env:COMPUTERNAME 5 | ) 6 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 7 | $RegistryKey1 = 'SendNotificationOnLowHDDSpace' 8 | 9 | $ReadRegistry = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath -RegistryKey $RegistryKey1 10 | $NotificationEnabled = $ReadRegistry 11 | 12 | $RegistryPathSub = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor\HDDList' 13 | $RegistryKeySub1 = 'Count' 14 | $ReadRegistrySub = Get-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub -RegistryKey $RegistryKeySub1 15 | $MonitoredDrives = $ReadRegistrySub 16 | 17 | 18 | $ListDrives = New-Object System.Collections.ArrayList 19 | $HddList = Get-RegistryRemoteList -Computer $Computer -RegistryPath $RegistryPathSub 20 | for ($i = 0; $i -lt $HddList.Count; $i++) { 21 | $Id = "Id$i" 22 | $Percentage = "Percentage$i" 23 | $Priority = "Priority$i" 24 | $SizeMB = "SizeMB$i" 25 | $UsePercentage = "UsePercentage$i" 26 | 27 | $Drive = @{ 28 | Id = $HddList.$Id 29 | Percentage = $HddList.$Percentage 30 | Priority = $HddList.$Priority 31 | SizeMB = $HddList.$SizeMB 32 | UsePercentage = $HddList.$UsePercentage 33 | } 34 | $ListDrives.Add($Drive) > $null 35 | } 36 | 37 | $Value = $NotificationEnabled 38 | $ValueConverted = $Value -As [NotificationStatus] 39 | Write-verbose "Return VALUE: $NotificationEnabled After CONVERSION: $ValueConverted" 40 | 41 | $Return = [ordered] @{ 42 | Name = 'HDD' 43 | ComputerName = $Computer 44 | MonitoredDrivesCount = $MonitoredDrives 45 | # TimeInterval = $TimeInterval 46 | # NotificationType = $NotificationType -As [NotificationType] 47 | NotificationEnabled = $NotificationEnabled #-As [NotificationStatus] 48 | MonitoredDrives = $ListDrives 49 | } 50 | return $Return 51 | } 52 | 53 | function Set-PulsewayLocalDiskSpace { 54 | [cmdletbinding()] 55 | param( 56 | [string] $Computer = $Env:COMPUTERNAME, 57 | $Drives, 58 | [NotificationStatus] $SendNotificationOnLowHDDSpace, 59 | [parameter(Mandatory = $False)][Switch]$PassThru 60 | ) 61 | $RegistryPath = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor' 62 | $RegistryKey1 = 'SendNotificationOnLowHDDSpace' 63 | 64 | $RegistryPathSub = 'HKLM:\SOFTWARE\MMSOFT Design\PC Monitor\HDDList' 65 | $RegistryKeySub1 = 'Count' 66 | 67 | $Count = Get-ObjectCount $Drives 68 | 69 | # Enable/disable notification 70 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPath ` 71 | -RegistryKey $RegistryKey1 ` 72 | -Value ($SendNotificationOnLowHDDSpace -As [int]) -PassThru:$PassThru 73 | 74 | # Count number of drives 75 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub ` 76 | -RegistryKey $RegistryKeySub1 ` 77 | -Value $Count -PassThru:$PassThru 78 | 79 | $i = 0 80 | foreach ($drive in $drives) { 81 | Set-RegistryRemote -Computer $Computer -RegistryPath $RegistryPathSub ` 82 | -RegistryKey "Id$i", "Percentage$i", "Priority$i", "SizeMB$i", "UsePercentage$i" ` 83 | -Value $drive.Id, $drive.Percentage, $drive.Priority, $drive.SizeMB, $drive.UsePercentage -PassThru:$PassThru 84 | $i++ 85 | } 86 | } 87 | function Get-Drive { 88 | param ( 89 | $Computer = $env:COMPUTERNAME 90 | ) 91 | $Drive = Get-CimInstance Win32_LogicalDisk -ComputerName $Computer | Where-Object { $_.DriveType -eq 3 } | Select-Object DeviceID, 92 | VolumeName, 93 | Size, 94 | FreeSpace, 95 | @{label = 'SizeGB'; expression = {[math]::round( ($_.Size / 1GB), 2) }}, 96 | @{label = 'FreeSpaceGB'; expression = {[math]::round( ($_.FreeSpace / 1GB), 2) }}, 97 | VolumeSerialNumber, 98 | PSComputerName 99 | return $Drive 100 | } 101 | function Set-DriveSettings { 102 | param ( 103 | $Drive, 104 | [int] $Percentage, 105 | [NotificationType] $Priority, 106 | [int] $SizeMB, 107 | [status] $UsePercentage 108 | ) 109 | $List = New-Object System.Collections.ArrayList 110 | foreach ($d in $drive) { 111 | $Disk = @{ 112 | Id = $d.VolumeSerialNumber 113 | Percentage = $Percentage 114 | Priority = $Priority -As [int] 115 | SizeMB = $SizeMB 116 | UsePercentage = $UsePercentage -AS [int] 117 | } 118 | $List.Add($Disk) > $null 119 | } 120 | return $List 121 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ### PSPulsewayManager 2 | 3 | Following is an easy to use `Powershell module` to control some of Pulseway Manager functionality. While `Pulseway Manager` offers GUI for enterprise deployments configuring some things from GUI is time consuming and not always easy. Also with this module you can in theory have different rules set based on different times. While `Pulseway` doesn't offer you that option you could schedule PowerShell script that will have diffrent rules at night and different rules at day... 4 | 5 | I will continue adding more functions when I will have requirement to do so for my needs. Otherwise... you can make request ;-) 6 | 7 | ####### Pulseway GET functions 8 | 9 | ``` 10 | CommandType Name Version Source 11 | ----------- ---- ------- ------ 12 | Function Get-PulsewayComputerName 0.5 PSPulsewayManager 13 | Function Get-PulsewayCPUAbove 0.5 PSPulsewayManager 14 | Function Get-PulsewayCPUBelow 0.5 PSPulsewayManager 15 | Function Get-PulsewayGroupName 0.5 PSPulsewayManager 16 | Function Get-PulsewayLocalDiskSpace 0.5 PSPulsewayManager 17 | Function Get-PulsewayMaintenanceMode 0.5 PSPulsewayManager 18 | Function Get-PulsewayMemoryLow 0.5 PSPulsewayManager 19 | Function Get-PulsewayMonitoredPortClosed 0.5 PSPulsewayManager 20 | Function Get-PulsewayMonitoredServices 0.5 PSPulsewayManager 21 | Function Get-PulsewayStatus 0.5 PSPulsewayManager 22 | ``` 23 | 24 | ####### Pulseway SET functions 25 | 26 | ``` 27 | Function Set-PulsewayComputerName 0.5 PSPulsewayManager 28 | Function Set-PulsewayCPUAbove 0.5 PSPulsewayManager 29 | Function Set-PulsewayCPUBelow 0.5 PSPulsewayManager 30 | Function Set-PulsewayGroupName 0.5 PSPulsewayManager 31 | Function Set-PulsewayLocalDiskSpace 0.5 PSPulsewayManager 32 | Function Set-PulsewayMaintenanceMode 0.5 PSPulsewayManager 33 | Function Set-PulsewayMemoryLow 0.5 PSPulsewayManager 34 | Function Set-PulsewayMonitoredPortClosed 0.5 PSPulsewayManager 35 | Function Set-PulsewayMonitoredServices 0.5 PSPulsewayManager 36 | ``` 37 | --------------------------------------------------------------------------------