January 29, 2018

PowerShell - Generate GUID

This PowerShell script uses NewGuid() method of the .Net Framework guid class to generate a Globally Unique Identifier. You can generate 1 GUID by running the script or specify how many GUID’s you want. See example below.

PS C:\> .\generate-guid.ps1
3e8c98a5-b352-4fe4-bcec-6ffe51ae8f84

PS C:\> .\generate-guid.ps1 3
90d92920-f41a-4c3f-86db-516be56edb72
dc9777b7-c3a2-4078-84bc-7fe270b556d6
940033c3-e487-4fd6-ab33-f97201595130


January 16, 2018

PowerShell - Monitoring Windows Service

This PowerShell script checks specific Windows Service. If service is in a stopped state script starts it and creates a log file.

Script usage example:
.\MonitorWindowsService.ps1 -ServiceName "SNMP Trap" -IntervalSeconds 30

Script above checks SNMP Trap service every 30 seconds. Any changes to the service state will be logged in “SNMP Trap_log.txt” file.