Scripting Tips: Take your PowerShell profile everywhere with Dropbox

Dev

Scripting Tips: Take your PowerShell profile everywhere with Dropbox

by Joshua Poehls
//

Scripting Tips is an on-again-off-again series for command line fiends. I’ll try to keep these short and sweet. To dig a ‘lil deeper you can find me on Twitter.


I’ll cover these prerequisites in brief, but for this tip I’m going to assume a few things:

  • You are running Windows and have PowerShell installed.
  • You are familiar enough with PowerShell to care about your $PROFILE.

What is PowerShell?
In short, PowerShell is a new scripting language from Microsoft designed to replace the use of batch files and VBScript for administrating and automating Windows machines. The language leverages the .NET Framework such that anything you can do with .NET you can do with PowerShell. Typically you will be using PowerShell from the command line but there are lots of other ways to use it.

What is a PowerShell profile?
PowerShell has the concept of a script that will run each time you launch PowerShell. This is a really handy place to put any functions that you want to be available all the time. Initialize some variables, create some aliases, anything you do here will be there when you need it.

What are we doing here?
I’m going to give you one possible solution for keeping all of your scripts and settings (i.e. your profile) in sync no matter which computer you are on. No copy/pasting. No more wearing that USB dongle around your neck – seriously, that just screams geek.

Most steps have a sample PowerShell command that will do the trick. So fire up PowerShell and put on your scripting hat ‘cuz here we go!

1) Get Dropbox.
Among other things, Dropbox makes keeping your files in sync across computers dead simple. If you aren’t using it you should be. It’s just that good.

2) Create a folder in Dropbox to hold your scripts.
PS> New-Item $dropboxscripts
Anywhere you see $dropbox, assume this to be the path to your Dropbox folder. By default on Windows 7 this is %USERPROFILE%Dropbox.

3) Copy your profile ps1 file into your new scripts folder.
PS> Copy-Item $PROFILE $dropboxscriptsprofile.ps1

4) Edit your profile ps1 file (the original one) and “dot source” the one in your Dropbox folder.
PS> ". $dropboxscriptsprofile.ps1" > $PROFILE

Pro Tip! As an alternative to dot sourcing your profile from Dropbox, you could instead create a symlink to it.
PS> fsutil hardlink create `"$PROFILE`" `"$dropboxscriptsprofile.ps1`"

Questions and comments are always welcome, just shoot me a note on Twitter.

More About the Author

Joshua Poehls

Software Architect
Tableau via PowerShell, Part 2: Saving Changes This is part 2 of my mini-series on exploring Tableau workbooks with PowerShell. If you missed it, you should read Part 1: Opening ...
Tableau via PowerShell, Part 1: Opening Workbooks In this mini-series I’m going to show you some cookbook style examples for using PowerShell to explore your Tableau workbooks. ...

See more from this author →

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072

×

Love our blog? You should see our emails. Sign up for our newsletter!