2022-12-01 09:50:58 +01:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
2023-04-11 10:48:59 +02:00
|
|
|
|
Check the PowerShell status
|
2022-12-01 09:50:58 +01:00
|
|
|
|
.DESCRIPTION
|
2023-04-11 10:48:59 +02:00
|
|
|
|
This PowerShell script queries the PowerShell status and prints it.
|
2022-12-01 09:50:58 +01:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./check-powershell
|
2023-04-17 21:33:22 +02:00
|
|
|
|
✅ PowerShell Desktop edition 5.1.19041.2673 (10 modules, 1458 cmdlets, 172 aliases)
|
2022-12-01 09:50:58 +01:00
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: Markus Fleschutz | License: CC0
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$Version = $PSVersionTable.PSVersion
|
|
|
|
|
$Edition = $PSVersionTable.PSEdition
|
2022-12-02 08:41:01 +01:00
|
|
|
|
$NumModules = (Get-Module).Count
|
|
|
|
|
$NumAliases = (Get-Alias).Count
|
2022-12-04 10:11:52 +01:00
|
|
|
|
if ($IsLinux) {
|
2023-04-17 21:33:22 +02:00
|
|
|
|
"✅ PowerShell $Edition edition $Version ($NumModules modules, $NumAliases aliases)"
|
2022-12-04 10:11:52 +01:00
|
|
|
|
} else {
|
|
|
|
|
$NumCmdlets = (Get-Command -Command-Type cmdlet).Count
|
2023-04-17 21:33:22 +02:00
|
|
|
|
"✅ PowerShell $Edition edition $Version ($NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)"
|
2022-12-04 10:11:52 +01:00
|
|
|
|
}
|
2022-12-01 09:50:58 +01:00
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
|
exit 1
|
2023-04-17 21:33:22 +02:00
|
|
|
|
}
|