Skip to content

Commit 952b84d

Browse files
committed
Improve list-profiles.ps1
1 parent e8040b7 commit 952b84d

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

Scripts/list-profiles.ps1

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,26 @@
1111
https://github.com/fleschutz/PowerShell
1212
#>
1313

14-
function ShowProfile { param([string]$Level, [string]$Name, [string]$Filename)
15-
"$Level Profile '$Name'"
16-
if (test-path "$Filename") {
17-
" at $Filename"
18-
} else {
19-
" at $Filename (file missing)"
14+
function ListProfile { param([int]$Level, [string]$Profile, [string]$Location)
15+
if (test-path "$Location") { $Existent = "yes" } else { $Existent = "no" }
16+
new-object PSObject -Property @{
17+
'Level' = "$Level"
18+
'Profile' = "$Profile"
19+
'Location' = "$Location"
20+
'Existent' = "$Existent"
2021
}
2122
}
2223

24+
function ListProfiles {
25+
ListProfile 1 "AllUsersAllHosts" $PROFILE.AllUsersAllHosts
26+
ListProfile 2 "AllUsersCurrentHost" $PROFILE.AllUsersCurrentHost
27+
ListProfile 3 "CurrentUserAllHosts" $PROFILE.CurrentUserAllHosts
28+
ListProfile 4 "CurrentUserCurrentHost" $PROFILE.CurrentUserCurrentHost
29+
}
30+
31+
2332
try {
24-
ShowProfile "1" "AllUsersAllHosts" $PROFILE.AllUsersAllHosts
25-
""
26-
ShowProfile "2" "AllUsersCurrentHost" $PROFILE.AllUsersCurrentHost
27-
""
28-
ShowProfile "3" "CurrentUserAllHosts" $PROFILE.CurrentUserAllHosts
29-
""
30-
ShowProfile "4" "CurrentUserCurrentHost" $PROFILE.CurrentUserCurrentHost
33+
ListProfiles | format-table -property Level,Profile,Location,Existent
3134
exit 0
3235
} catch {
3336
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"

0 commit comments

Comments
 (0)