Accessing Profile Scripts

by Mar 5, 2010

Profile scripts are executed automatically when PowerShell starts. The paths to these scripts can be found in $profile:

$profile | gm *Host* | % { $_.Name } | % {
$rv = @{}; $rv.Name = $_
$rv.Path = $profile.$_
$rv.Exists= (Test-Path $profile.$_)
New-Object PSObject -Property $rv
} | Format-Table -AutoSize
Name Path Exists
—- —- ——
AllUsersAllHosts C:\Windows\…ps1 True
AllUsersCurrentHosts C:\Windows\…ps1 False
CurrentUserAllHosts C:\Users\…ps1 True
CurrentUserCurrentHost C:\Users\…ps1 True

Twitter This Tip! ReTweet this Tip!