0

#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:

Filed in: Columns, Tips and Tricks Tags: , , ,

Leave a Reply

Submit Comment

© 2016 PowerShell Magazine. All rights reserved. XHTML / CSS Valid.
Proudly designed by Theme Junkie.
%d bloggers like this: