Saturday, May 22, 2021

Get Response Status Code with PowerShell Invoke-RestMethod

 As DevOps engineers, you get requirements to do scripts to perform several actions on application or get status of the application backend  using API calls. This post explains small issue that we experience while writing PowerShell scripts to trigger APIs.

Issue: Invoke-RestMethod cannot be used to get the return HTTP status from the API. API call failed with mentioning -StatusCodeVariable  is not valid. You can learn more about Invoke-RestMethod from here.

Wednesday, May 19, 2021

Run PowerShell script automatically after reboot

If you are working with scripting languages, you might have to do various scripts to fulfill requirements such as reboot the machine in the middle of installation until installation fully done. As scenario, You can think of Windows updates and the Reboot and check for further updates. This blog explains how to achieve it using schedule tasks.

Let's try to understand the script step by step.

  • Following first few lines of the script is for make sure the script is run as administrator.