#PSTip Find all PowerShell Profiles from $PROFILE

Note: This tip requires PowerShell 2.0 and above

I have always wanted to see what all PowerShell profiles are defined and in-use on a system. Sometimes, this is very crucial to understand what exactly is causing errors in scripts.

The $PROFILE automatic variable shows the current PowerShell Profile in use within the host. Now, a less known fact is that the $PROFILE also has extended properties that show different PowerShell path properties.

Let us see how we can use this to find all PowerShell profiles in use.

function Get-PSProfile{
 $PROFILE.PSExtended.PSObject.Properties |
 Select-Object Name,Value,@{Name='IsExist';Expression={Test-Path -Path $_.Value -PathType Leaf}}
}

This gives us an output similar to:

Share on: