PowerShell - Organizing my Scripts

2013/10/22 | 2 minute read |

With time, the number of PowerShell scripts I write keeps growing and growing, and I feel it is getting more and more difficult to find what I have done in the past. I won’t say that all my scripts are great! Especially when I look at the scripts I wrote back in 2010/2011 or even 2012. I’m really happy to see the evolution as I keep learning about PowerShell. And honestly … I think it is really fun to update old scripts, and it is always a good topic for a new blog post.

Today I will talk about my scripts directory, how I maintain it, which naming convention I use, what are my bottlenecks, my preferences …

Naming Convention

Personally I organize my directories this way: -- For example, you would get those kind of folders for my scripts: AD-SITE-Find_Missing_subnets AD-COMPUTER-Windows_Server_2012 VMWARE-HOSTS-Resources_Report EXCHANGE-MAILBOX-Top_100_user

For my functions I have different standard, I had the prefix FUNCT, so those can be reused in other scripts (Dot Sourcing, mostly). FUNCT-AD-SITE-Get-Subnets FUNCT-AD-SITE-Set-Subnets FUNCT-VMWARE-VM-Enable-CopyPaste FUNCT-VMWARE-VM-Disable-CopyPaste

Other preferences

  • Keep the script in one place! That’s why I use SkyDrive (see below), easier to maintain when you access your scripts from different devices/locations.

  • I don’t like space, I never use space in the name of a folder or a script, always use the underscore “_” or a dash “-“ characters.

  • Instead of using files, I prefer to use folders for each script or function, especially if I want to keep track of different versions. Also Some scripts might need some XML config file, CSV file input etc… or just because your script is a project of multiple PowerShell script/functions files.

BottleNecks/Missing items

  • Versioning/Version Control

  • I did not play with any solution yet, it would be great to have tool that can do the tracking job for me

  • Collaboration Tool

  • I would like something like Google Docs where you see what each people are doing/typing, and obviously a solution that would support PowerShell files…

Note: I would be interested to hear how you guys get your scripts organized, I’m always looking for ways to improve my folders names and structures.AlsoI did not look into version control solutions yet, if you have tried any let me know.

SkyDrive

I store all my scripts on Skydrive, Windows 8.1 comes with it ! Plus, Skydrive allows you to edit your file online! Pure Awesomeness! :-) The only things missing are: We can’t embed the files to another website, No version control unless you use the Pro version, No live collaboration tool.

YES! you can edit your script right into the browser! :-)

Leave a comment