mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-23 00:13:36 +01:00
39 lines
1017 B
PowerShell
Executable File
39 lines
1017 B
PowerShell
Executable File
<#
|
|
.SYNOPSIS
|
|
list-profiles.ps1
|
|
.DESCRIPTION
|
|
Lists your PowerShell profiles
|
|
.EXAMPLE
|
|
PS> ./list-profiles
|
|
.NOTES
|
|
Author: Markus Fleschutz · License: CC0
|
|
.LINK
|
|
https://github.com/fleschutz/PowerShell
|
|
#>
|
|
|
|
function ListProfile { param([int]$Level, [string]$Profile, [string]$Location)
|
|
if (test-path "$Location") { $Existent = "yes" } else { $Existent = "no" }
|
|
new-object PSObject -Property @{
|
|
'Level' = "$Level"
|
|
'Profile' = "$Profile"
|
|
'Location' = "$Location"
|
|
'Existent' = "$Existent"
|
|
}
|
|
}
|
|
|
|
function ListProfiles {
|
|
ListProfile 1 "AllUsersAllHosts" $PROFILE.AllUsersAllHosts
|
|
ListProfile 2 "AllUsersCurrentHost" $PROFILE.AllUsersCurrentHost
|
|
ListProfile 3 "CurrentUserAllHosts" $PROFILE.CurrentUserAllHosts
|
|
ListProfile 4 "CurrentUserCurrentHost" $PROFILE.CurrentUserCurrentHost
|
|
}
|
|
|
|
|
|
try {
|
|
ListProfiles | format-table -property Level,Profile,Location,Existent
|
|
exit 0
|
|
} catch {
|
|
"⚠️ Error: $($Error[0]) ($($MyInvocation.MyCommand.Name):$($_.InvocationInfo.ScriptLineNumber))"
|
|
exit 1
|
|
}
|