#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

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: , ,
© 1011 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: