1

#PSTip Script sharing using Dropbox

When I was asked to provide some PowerShell tips, I decided to look at the first possible place–my $profile. When I started working with PowerShell few years ago I was looking for solution to have scripts available on all of my computers. Then I found easy solution–Dropbox. At the moment I have this structure:

PS> Show-Tree Dropbox:\PowerShell -Depth 1
Dropbox:\PowerShell
├──Books
├──Mercurial
├──My
├──Papers
├──Presentations
├──Profile
├──pse_1.0.beta.x86
├──Scripts
├──Trainings
└──v3

You can see that for showing this structure, I’ve used Show-Tree function, a part of PowerShell Community Extensions. If you haven’t checked that one out yet, it’s time for it now. It has really a lot of very useful functions.

First line of my $PROFILE.AllUsersAllHosts is:

PS> Get-Content $PROFILE.AllUsersAllHosts | Select -First 1
New-PSDrive -Name Dropbox -PSProvider FileSystem -Root "c:\Documents and Settings\Moravec\My Documents\Dropbox" | Out-Null

This allows me to have available anything I am currently working on (plus all my favorite books). I’ve also modified the $PSModulePath automatic variable:

$env:PSModulePath += ';Dropbox:\PowerShell\Profile'

Just to ensure that when I add anything to Dropbox module folder, I’ll have it everywhere. For the same reason I created new “profile” script which I use for synchronizing my frequently using scripts and functions:

. Dropbox:\PowerShell\Profile\profile_Dropbox.ps1

I don’t use the same profile on all computers. On my home computer it’s not necessary to call, for example, a module I use for work with Configuration Manager. I know that I will never connect to my infrastructure from a personal netbook.

Filed in: Columns, Tips and Tricks Tags: , ,

One Response to "#PSTip Script sharing using Dropbox"

  1. Josh says:

    Nice tip. I also have a Dropbox: PSDrive. I also set up a symbolic link to relocate the WindowsPowerShell directory under Documents to Dropbox.

    From cmd.exe:
    cd %USERPROFILE%
    mklink /D .DocumentsWindowsPowerShell .DropboxPowerShell

    Now my scripts, profile, modules, etc are always up to date on the various machines I use.

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: