Improved list-profiles.ps1

This commit is contained in:
Markus Fleschutz 2021-02-24 19:44:05 +01:00
parent daf53ac0c4
commit a31375a523

View File

@ -6,9 +6,26 @@
.NOTES Author: Markus Fleschutz / License: CC0
#>
try {
$PROFILE | select-object *
function ShowProfile { param([int]$Level, [string]$Name, [string]$Filename)
write-output "$($Level). '$($Name)'"
if (test-path "$Filename") {
write-output " at $($Filename) containing:"
$Content = get-content $Filename
write-output "$Content"
} else {
write-output " at $Filename (file non-existent)"
}
write-output ""
}
try {
write-output ""
write-output "PowerShell Profiles"
write-output "-------------------"
ShowProfile 1 "AllUsersAllHosts" $PROFILE.AllUsersAllHosts
ShowProfile 2 "AllUsersCurrentHost" $PROFILE.AllUsersCurrentHost
ShowProfile 3 "CurrentUserAllHosts" $PROFILE.CurrentUserAllHosts
ShowProfile 4 "CurrentUserCurrentHost" $PROFILE.CurrentUserCurrentHost
exit 0
} catch {
write-error "ERROR: line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"