4 things which I learned for 6 years during work with Powershell

Hi, Damian Garbus here and this is next post on Poshland blog. Today I want to write about 4things I learned for 6 years from Powershell. Now, you probably think that it’s only four? I won’t write about technical skills because it’s impossible to list them. I want to write about my approach to work with Powershell. Ok so let’s list them.


Write scripts in order to any people can use them
The script or function should have Comment Based Help
Write scripts based on functions
Always use versioning of your script


Write Powershell scripts in order to any people can use them

For the first look it’s obvious but few years ago I don’t know this. Often I was writing scripts only for me without functions, param. If I wanted to use the script, which I wrote before, I always had to edit this. If someone wanted to use my script It was hard to understand what script do. 

Now, all my scripts I write with best practice. I always want to use param block, functions, try-catch block. You can use my 5 steps to prepare the first final version of Powershell script. I know that sometimes is no time to use all of these but always during script writing, you should think that this script will be used many times and probably by more than one person.


Think that your script will be used many times and probably by more than one person.

The Powershell script or function should have Comment Based Help

It’s really important because after a few months you can forget the details of your script. With Comment Based Help it’s easy to remind of script details and others people can easily check what this script doing.

Now I use the script template and always write the synopsis at the beginning of the script. It takes some time more during write script or function but gives many advantages.


It takes some time more during write script or function but gives many advantages.

Write scripts based on functions

Please remember. Always use functions in your scripts. Build your resource with your functions. Functions will help you write future script faster. 

I have created the project on my GitLab server for functions. All the functions I have in one place. During writing new scripts I can use many of them and don’t write it again.


During writing new scripts I can use many of them and don’t write it again.

Always use versioning of your script

A few years ago I didn’t use the code versioning system. Every one of my scripts was holding on my hard drive. When the script doesn’t work properly it’s hard to check when the issue has begun. Sometimes when you want to check the script before last modification. Without versioning, you can’t do this.

Today always I use my GitLab server. It’s the second time when I write about it in this post so I think that I will write about it in the future for more details. However, I can easily return to any version before. Script versioning system helps me to be more productive in the script creation.


Script versioning system helps me to be more productive in the script creation.

Conclusion

In this post on my blog, I want to show what is my approach to script writing. Each script written by me teaches me new things. It’s the best thing during work with Powershell for me. Please let me know in comments what did you learned during work with Powershell.

Get Access to Poshland Resources for FREE!!!

Signup now and receive an email once I publish new content.

I agree to have my personal information transfered to MailerLite ( more information )

I will never give away, trade or sell your email address. You can unsubscribe at any time.