Powershell‎ > ‎

Profile


if (!(Test-Path $profile)) {new-item -path $profile -type file -Force}
notepad $profile


List of Profile files

http://msdn.microsoft.com/en-us/library/bb613488(VS.85).aspx

 

http://www.computerperformance.co.uk/powershell/powershell_profile_ps1.htm

%userprofile%\My Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Prompt

http://huddledmasses.org/powershell-power-user-tips-a-better-prompt/


#My Profile
. "$([System.IO.Path]::GetDirectoryName($PROFILE))\Set-Prompt.ps1"
IF (Get-PSSnapin | where {$_.name -eq "quest.activeroles.admanagement"}) 
    {write-host "Quest Active Roles snapin already loaded"}
Else
    {add-PSSnapin  quest.activeroles.admanagement}

Import-Module pscx
#Import-Module activedirectory

#This is slow to run so I don't want it in my profile but sometimes I just copy and paste it.
Write-host "`$Me = Get-QADUser -IncludeAllProperties" "$(gc Env:\USERDOMAIN)\$(gc Env:\USERNAME)"
Write-host "`$PC = Get-QADComputer (gc Env:\COMPUTERNAME)"

 

If launching PowerCLI connect to vcenter

http://www.wooditwork.com/2010/08/11/pimping-your-powershell-profile/

# VMware vSphere PowerCLI
if (Get-PSSnapin -Name "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue)
{
    Write-Host "Connecting to VCenter" -ForegroundColor Green
    Connect-VIServer vcenterserver
}



Change Background if run as admin 

%windir%\system32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1

http://www.interact-sw.co.uk/iangblog/2007/02/09/pshdetectelevation

$CurrentID=[System.Security.Principal.WindowsIdentity]::GetCurrent()
$prp=new-object System.Security.Principal.WindowsPrincipal($CurrentID)
$adm=[System.Security.Principal.WindowsBuiltInRole]::Administrator
$IsAdmin=$prp.IsInRole($adm)
if ($IsAdmin)
{
(get-host).UI.RawUI.Backgroundcolor="DarkRed"
#clear-host
Comments