Don’t you hate it when you can’t find what you need? In our department, we share all of our scripts in a single folder. This folder had some serious organizational issues. Duplicate scripts, missing modules, random folders, etc. Finding that one script that you need doesn’t have to be hard! In this guide, we will create a PowerShell script store and learn an awesome trick to make content searching so much easier!

Organizing and Linking to Your PowerShell Script Store

In the root of your current script folder, create four sub-folders named: Scripts, Modules, Tasks and Tools. If your root folder is named scripts, it may seem redundant to have a sub-folder with the same name but stay with me. Your structure should now look like this:

Your Modules folder is now populated. You have universal access to any cmdlet that you will use on a regular basis! You can even make PowerShell load your modules at startup automatically. Simply edit your PowerShell profile and import the modules. Be sure to specify a UNC path instead of a network drive mapping when using import-module.

The next step is to organize your existing scripts into your Scripts sub-folder. I prefer grouping scripts by function. All scripts that work with MDT are grouped into a MDT folder. Script altering AD Groups are placed in an AD Groups folder.

This method will instantly make finding scripts so much easier. If scripts have multiple functions, place the script into one folder and place a shortcut to it in the other folder. The screenshot below shows an organization that works for us.

We now have an organized scripts sub-folder and a populated modules folder. If you use Scheduled Tasks with PowerShell (ex: Self Service Password Resets), you will want a central place to back up those jobs. We use the Tasks sub-folder for this and backup any central schedule task on a regular basis.

Some of your scripts might reference an external application (such as a tool in the PSTools suite). When a script uses a tool like this, it is helpful to ensure that the tool is available across your domain. Referencing the tool from your PowerShell store makes this possible. When you use an external tool, copy it to your Tools sub-folder and point your script to it.

Search Within Your Scripts with Indexing

All of the organizing in the world does you little good if you can’t remember the script’s name! To make searching effortlessly easy, we can modify the Indexing service to search within a script. This will allow you to search for something like Get-QADComputer and see every script containing that cmdlet!

In Windows Explorer, right click on your PowerShell script store and select Make Available Offline. If you prefer to do this for your entire department, you can configure the following Group Policy setting: User Configuration\Administrative Templates\Network\Offline Files\Administratively assigned offline files.

Next, open Indexing Options from the Control Panel and select Advanced – File Types. Scroll down until you see PS1. Select it and change the index filter to Index Properties and File Contents. The filter description should change to plain text filter.

Press OK twice and wait about 15 minutes for re-indexing to complete. You should now be able to search for contents within your PowerShell scripts! If you wish to search within PowerShell modules, console files, etc, change their Indexing filter as well.

One Final Tip – Favorites

Make accessing the PowerShell Script store super easy! Drag the root folder over to your Favorites location in explorer, located on the far left. In the picture below, I’ve added our script store and the Group Policy Search Engine.

If you use Folder Redirection to redirect your links folder, this shortcut will be available on every computer that you use!