My typical work situation involves up to four different computers at any time. Some are on the same network while others lie across a VPN connection. I have dozens of various Powershell modules that I use on a daily basis. I've always found it to be a challenge to ensure a consistent PowerShell environment across all of my computers until I had an epiphany one day. Modules are just text files placed in a specific location on your computer. Why not use Dropbox?

Windows Symbolic Links

The problem with using a cloud sync product like Dropbox is that you're forced to put everything into a single folder like C:\Dropbox.

I could change the Dropbox folder to point to another folder but I still want to use it for other stuff. Therein lies the dilemma. If only I could create a couple subfolders in my main Dropbox folder and just link to those folders in all my computers I'd be in business.

Enter symbolic links.

Symbolic links are a great way to essentially create shortcuts to folders much like you have .LNK file that create shortcuts on your desktop.

Using symbolic links I can now make Windows think that my modules folder that exists in C:\Dropbox\PowerShellModules is actually at C:\Program Files\WindowsPowerShell\Modules and my profile that's actually in the C:\DropBox\ProfileFolder folder is in the C:\Users\abertram\Documents\WindowsPowerShell folder.

How-To Steps

  1. Install DropBox on all computers.
    So what do we need to make this happen? First, I'm assuming you have Dropbox installed on all of your computers. Also, I always change my default Dropbox path to C:\Dropbox just in case the username is different across them.
  2. Find your module folder path.
    Next, you'll need to figure out the place where PowerShell is looking for your modules. These paths are in the $env:PSModulePath environment variable. I want all of my modules in the system-level module directory in C:\Program Files\WindowsPowerShell\Modules. This will be my "linked" folder that will link to the Dropbox folder where the modules will actually be stored.
  3. Create the modules DropBox folder and move all modules from the "real" folder to the DropBox folder.
    `mkdir C:\DropBox\PowerShell\Modules
    Move-Item -Path C:\Program Files\WindowsPowerShell\Modules -Destination C:\DropBox\PowerShell
    Be sure you moved the entire folder. You can't just move the files inside the folder.
  4. Create the symbolic link.
    Next, I'll need to show you how to create symbolic links in Windows. This can be done with the mklink.exe utility. mklink.exe allows you to specify two folder paths; the linked path and the real path.

    In my instance, I have all my modules in the C:\Dropbox\PowerShell\UserModules folder but I want PowerShell to think they're in the C:\Program Files\WindowsPowerShell\Modules folder. I'll use mklink.exe to make this happen.

    mklink /d "C:\Program Files\WindowsPowerShell\Modules" "C:\Dropbox\PowerShell\UserModules"

    You'll then see a Modules folder shortcut where your old Modules folder used to be.
  5. Ensure PowerShell still sees your modules.
    You can now simply put all of your PowerShell modules in your DropBox folder and feel safe that they are all getting backed up into the cloud! �Not too fancy but gets the job done. Now when I come to a new machine I simply create the sym link and point it to my DropBox folder and it works like a champ.

Join the Jar Tippers on Patreon

It takes a lot of time to write detailed blog posts like this one. In a single-income family, this blog is one way I depend on to keep the lights on. I'd be eternally grateful if you could become a Patreon patron today!

Become a Patron!