Skip to content

Latest commit

 

History

History
34 lines (28 loc) · 1.04 KB

File metadata and controls

34 lines (28 loc) · 1.04 KB
function Get-PowerShellProfileDetails {
    try {
        $profilePaths = @{
            AllUsersAllHosts       = $PROFILE.AllUsersAllHosts
            AllUsersCurrentHost    = $PROFILE.AllUsersCurrentHost
            CurrentUserAllHosts    = $PROFILE.CurrentUserAllHosts
            CurrentUserCurrentHost = $PROFILE.CurrentUserCurrentHost
        }

        $level = 1
        $profiles = foreach ($key in $profilePaths.Keys) {
            $location = $profilePaths[$key]
            $existent = if (Test-Path $location) { "True" } else { "False" }
            New-Object PSObject -Property @{
                Level       = $level
                Profile     = $key
                Location    = $location
                Existent    = $existent
                ParentFolder = Split-Path $location -Parent
            }
            $level++
        }

        $profiles | Select-Object Profile, Level, Location, Existent, ParentFolder
    } catch {
        "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
    }
}