I have no idea what I'm doing.

Wednesday, November 27, 2013

Sauron's PowerShell profile in 3 easy steps.

Wouldn't it be nice to share the same PowerShell profile at each of your workstations?  Sharing your influence all throughout Middle-DataCenter...  It's not very tricky, here's how:

1.  Get your cloud syncing app up and running (let Dropbox be the ring-bearer).
2.  Create a location for your one-ring profile, some place like: c:\dropbox\powershell\hobbiton.ps1
3.  Edit your default PowerShell profile to point to the one-ring profile.  So, from the PS command prompt, type:
notepad $profile
   This opens your default profile in notepad... now add this one-liner for the redirection:
. "c:\dropbox\powershell\hobbiton.ps1"
From now on, each workstation can reference the same hobbiton.ps1 profile.  Now your influence can now be felt all across the world.  What sort of influence? say ye fellow traveler...

How about a colored prompt?  BAM:
function Prompt
    $promptString = "PS " + $(Get-Location) + ">"
    # Custom color for Windows console
    if ( $Host.Name -eq "ConsoleHost" )
        Write-Host $promptString -NoNewline -ForegroundColor Cyan
    # Default color for the rest
        Write-Host $promptString -NoNewline
    return " "
Sprinkle some of this code magic into your hobbiton.ps1 profile, then set out for an adventure on each of your workstations.


No comments:

Post a Comment