Powershelling properly

Powershelling properly

The best ways to be able to look at your scripts some weeks/months/years after writing it is to script properly.

Here below is the format at always use, I use it as a script template :

		Write a little Synopsis about the script purpose

        AUTHOR : Chris ROUALIN - powershelltips.fr
		Write a little description about the script purpose

	.PARAMETER  Subject
		Using -Subject parameter for the script.

	.PARAMETER  Message
		Using -Body parameter for the script.

		PS C:\>.\Script-Template.ps1 -Subject "Powershell" -Message "Show how to use Powershell script template"

        This is just an example of a notes displayed in help


This part make your script reachable with the Get-Help command :

roualin 2020-02-24_09h29_35-300x185 Powershelling properly


Then, use some comments to create “section” in your script, such as :




##### MAIN

So your powershell script will be easy to read/modify, adapt if the script is moved or if any variable has to be modified…

Also, never forget to comment as much as you can your script ! Every “block” need a comment to make it readable quickly !

Remember also that aliases are not welcome in a script, because not everyone knows what “%” means for example !

Cheers !

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

How to whitelist website on AdBlocker?

How to whitelist website on AdBlocker?

  1. 1 Click on the AdBlock Plus icon on the top right corner of your browser
  2. 2 Click on "Enabled on this site" from the AdBlock Plus option
  3. 3 Refresh the page and start browsing the site