Creating a PowerShell Profile

Inspired by this Hey, Scripting Guy! post, I decided it was time to figure out exactly what a PowerShell profile could do. If you’re like me, you open a PowerShell window, load a module, do some quick commands, come back a few hours later, load some more modules, and so on – all on the same PoSH window.

First read the article, then create your own PowerShell profile as follows:

[code language=”powershell”]
New-Item -ItemType file -Path $profile -Force
Ise $profile

Then create your profile. As an example, this profile will take a moment to open, but it loads PowerCLI and Citrix XenDesktop snapins, sets the prompt and window title.

[code language=”powershell”]

$WinTitle = "PowerShell $($PSVersionTable.PSVersion.Major).$($PSVersionTable.PSVersion.Minor) – Modules Loaded:"

# Load XenDesktop Snapins
"Loading XenDesktop SnapIns…"
asnp Citrix*
$WinTitle += " XenDesktop"

# Load PowerCLI
If($env:PROCESSOR_ARCHITECTURE -like "*AMD64*"){$PCLIPath = "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"}
Else{$PCLIPath = "C:\Program Files\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"}

If (Test-Path $PCLIPath)
"Loading PowerCLI…"
Import-Module $PCLIPath 4>$Null
$WinTitle += " PowerCLI"

function prompt {">_ "}

$host.ui.RawUI.WindowTitle = $WinTitle

Set-Location C:\


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.