Why writing PowerShell script

This is one of the most interesting question about writing in PowerShell script... why we need it?

PowerShell was released in 2006 and I have no interest in it for so many years until I was doing the repeating works on many servers. This includes installing applications into many servers, updating the servers, checking the server health, checking the database backup, reviewing the event logs, ... all repetitive tasks should be done and can be done better with scheduled program.

Here's some reasons why you need to write script with PowerShell:

  • Consistency issue - installing web applications into IIS by using PowerShell - as a result, the application pool name, folder permission will be definitely looks the same. No more issue with typo error or application name with different upper and lower cases. The web application setup in all server will be consistent. No more naming issue. No more directory structure issue (because the script must work for the same directory structure which forces us to have consistent directory structure).
  • Reduce handling the boring and repetitive process - updating the web application - this task is quite straightforward. We just need to download the file, and unzip the update... but if we are doing manually, then, there is a chance that we might miss out to do some testing on the changes. With writing an update script, we can have the script to do pre-update checking and do post-update checking. Nothing will be missed out any more.
  • Before it goes bad - checking server health - you may write script that runs daily, weekly and monthly checkup. And you must avoid that it sending the full health report to you for reviewing. The health check report will be sending to you only if there is something bad is going to happen or has happened. Such as the C drive is 90% full.
  • Prevent loosing any the precious data - check database backup - we have a daily scheduled backup and we review the backup status on a weekly basis. If you write a script to check the backup status, you may schedule it to run daily to check whether the backup really runs. For me, I have a script that copy the backup files to another server, restore the database from backup and run some SQL script to review some key data to ensure that everything is intact.
  • You need an eye on the baby before it cries - reviewing the event log with PowerShell script - now, you don't have to logon to the server, open the Event Viewer and scroll through all the logs. What you need to do is to write a script, load the event log that you are interested and send an email to notify you. Such as "Invalid user name" or "Invalid password" or someone is trying to hack through the Remote Desktop (RDP). I'm also watching another critical that is "disk IO" error before the entire hard disk became inaccessible.

Writing PowerShell script is fun and it really reduces your burden in running the checklist manually. This is the main reason why computer has been invented... to avoid wasting your life in all these repetitive tasks.

Now you can handle more tasks in your job. :)


Comments

Popular posts from this blog

Scheduled task in Windows Task Scheduler - part 3

Create scheduled task in Windows Task Scheduler

Get all website entries in IIS