You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
976 B

  1. # PowerShell
  2. You can use [PowerShell](https://msdn.microsoft.com/en-us/powershell/mt173057.aspx)
  3. and Windows Task Scheduler to automate various tasks on a Windows system.
  4. From within a PowerShell script it is also easy to ping SITE_NAME.
  5. Here is a simple PowerShell script that pings SITE_NAME. When scheduled to
  6. run with Task Scheduler, it will essentially just send regular "I'm alive" messages.
  7. You can of course extend it to do more things.
  8. ```bash
  9. # inside a PowerShell script:
  10. Invoke-RestMethod PING_URL
  11. ```
  12. Save the above to e.g. `C:\Scripts\healthchecks.ps1`.
  13. Then use the following command in a Scheduled Task to run the script:
  14. ```bash
  15. powershell.exe -ExecutionPolicy bypass -File C:\Scripts\healthchecks.ps1
  16. ```
  17. In simple cases, you can also pass the script to PowerShell directly,
  18. using the "-command" argument:
  19. ```bash
  20. # Without an underlying script, passing the command to PowerShell directly:
  21. powershell.exe -command &{Invoke-RestMethod PING_URL}
  22. ```