Find out what you should do with Powershell script to prepare the first final version. In this post, I list 4 based tasks that should be prepared. Check this out
-
-
Prepare log file during running script
-
-
-
List requirements for this script
-
-
-
Test script in a test environment.
-
-
-
Script Optimization and test again
-
Write PowerShell comment-based help
-
Prepare log file during running Powershell script
The best practice is that scripts which are started in task scheduler should generate log file what happened. It’s very helpful when something went wrong and then you can open log files and check error. If the script isn’t running in task scheduler log should display in Powershell console.
List requirements for this script
I mean all Powershell script should have own requirements. Now is many Powershell version, not all command and parameters run in all version. It’s not important if we create the script for us, for our client or in order to publish on the internet. Often it can save time for many people and you because you won’t receive questions with simple problems.
Test script in a test environment
Of course, the first step is to test the script in a test environment. The best practices are to have separated test environments. Everyone can make own virtual machine on his desktop and test scripts here. On the internet are many examples how to do this, eg here. When we are sure that our script works, we can the next step.
Script Optimization and test again
I know that it’s difficult to find time for optimization if the script works well. Sometimes it’s enough to check line by line of our script. 30 minutes, that’s all. If you can show your script to another person for this it will be awesome. Sometimes you cannot see something that can see another Powershell geek.
Write PowerShell comment-based help
When our script works great, fast and you are happy about this now you can do finally step and write comment-based help. It’s very important to include author, description, examples of use, parameters description. A small thing, but will save time for the next users of your scripts.
Maybe you have more steps to share with others. Please comment below.