mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-27 09:08:58 +01:00
Improve check-powershell.ps1
This commit is contained in:
parent
c89673f442
commit
e2aed21d87
@ -5,23 +5,33 @@
|
||||
This PowerShell script queries the PowerShell status and prints it.
|
||||
.EXAMPLE
|
||||
PS> ./check-powershell.ps1
|
||||
✅ PowerShell 5.1.19041.2673 Desktop edition (10 modules, 1458 cmdlets, 172 aliases)
|
||||
✅ PowerShell 5.1.19041.2673 Desktop edition (1 profile, 10 modules, 1458 cmdlets, 172 aliases)
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
function GetNumberOfProfiles {
|
||||
[int]$count = 0
|
||||
if (Test-Path $PROFILE.AllUsersAllHosts) { $count++ }
|
||||
if (Test-Path $PROFILE.AllUsersCurrentHost) { $count++ }
|
||||
if (Test-Path $PROFILE.CurrentUserAllHosts) { $count++ }
|
||||
if (Test-Path $PROFILE.CurrentUserCurrentHost) { $count++ }
|
||||
return $count
|
||||
}
|
||||
|
||||
try {
|
||||
$version = $PSVersionTable.PSVersion
|
||||
$edition = $PSVersionTable.PSEdition
|
||||
$numProfiles = GetNumberOfProfiles
|
||||
$numModules = (Get-Module).Count
|
||||
$numAliases = (Get-Alias).Count
|
||||
if ($IsLinux) {
|
||||
"✅ PowerShell $version $edition edition ($numModules modules, $numAliases aliases)"
|
||||
"✅ PowerShell $version $edition edition ($numProfiles profile, $numModules modules, $numAliases aliases)"
|
||||
} else {
|
||||
$numCmdlets = (Get-Command -Command-Type cmdlet).Count
|
||||
"✅ PowerShell $version $edition edition ($numModules modules, $numCmdlets cmdlets, $numAliases aliases)"
|
||||
"✅ PowerShell $version $edition edition ($numProfiles profile, $numModules modules, $numCmdlets cmdlets, $numAliases aliases)"
|
||||
}
|
||||
exit 0 # success
|
||||
} catch {
|
||||
|
Loading…
Reference in New Issue
Block a user