Start-Job,Variables, and ntfy.sh

So I’m working on a script that can check on the status of machines that are being re-imaged. Since there files that can be expected to appear as it re-images, we can use that to gauge the success/failure of the process. However, that is time consuming and to prevent looping a group of machines in one process, I needed a way to fork out into child processes. This is where Start-Job comes in.

Start-Job supports a number of features, but the primary one I needed was ArgumentList. That enables me to push variables through to the child process, allowing me to drop in shared code, static or already defined variables/objects, things the child process would need to function. The example code below shows a very rudimentary concept that is expandable to do even more. Once I finish the actual checking tool, I’ll make a post detailing that. For now, this is what today yielded.

(I'm a dipstick, and I re-used a code block, so I've lost what I had here. I'll fix it later.)

In the code above you can also see me using https://ntfy.sh. That tool allows a user to send messages to topics which trigger notifications on devices/browsers that are subscribed to the topic. I am running my own instance of the tool, but the creator does offer a free tier to try it out and see what you think. It utilizes http POST/PUT requests, or you can use the client app on your OS of choice. The documentation is quite robust, and he has examples for multiple programming languages. I elected to do the http method since it’s fairly universal, can be researched for the system I’m working with, and doesn’t require the app to be installed. This makes my code portable, which is always my end goal. Go here to get started using ntfy.sh.

Until next time… and there will be a next time.

Leave a Reply

Your email address will not be published. Required fields are marked *