PowerShell/Scripts/list-profiles.ps1

37 lines
835 B
PowerShell
Raw Normal View History

2021-04-21 19:53:52 +02:00
<#
2021-07-13 21:10:02 +02:00
.SYNOPSIS
list-profiles.ps1
.DESCRIPTION
Lists your PowerShell profiles
.EXAMPLE
PS> .\list-profiles.ps1
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
2021-08-03 15:53:57 +02:00
Author: Markus Fleschutz
License: CC0
2021-02-24 19:03:31 +01:00
#>
2021-04-18 18:12:19 +02:00
function ShowProfile { param([string]$Level, [string]$Name, [string]$Filename)
"$Level Profile '$Name'"
2021-02-24 19:44:05 +01:00
if (test-path "$Filename") {
2021-04-18 18:12:19 +02:00
" at $Filename"
2021-02-24 19:44:05 +01:00
} else {
2021-04-18 18:12:19 +02:00
" at $Filename (file missing)"
2021-02-24 19:44:05 +01:00
}
}
2021-02-24 19:03:31 +01:00
2021-02-24 19:44:05 +01:00
try {
2021-04-18 18:12:19 +02:00
ShowProfile "1" "AllUsersAllHosts" $PROFILE.AllUsersAllHosts
""
ShowProfile "2" "AllUsersCurrentHost" $PROFILE.AllUsersCurrentHost
""
ShowProfile "3" "CurrentUserAllHosts" $PROFILE.CurrentUserAllHosts
""
ShowProfile "4" "CurrentUserCurrentHost" $PROFILE.CurrentUserCurrentHost
2021-02-24 19:03:31 +01:00
exit 0
} catch {
2021-05-02 21:30:48 +02:00
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
2021-02-24 19:03:31 +01:00
exit 1
}