2022-12-01 09:50:58 +01:00
|
|
|
|
<#
|
|
|
|
|
.SYNOPSIS
|
2023-04-11 10:26:05 +02:00
|
|
|
|
Check PowerShell details
|
2022-12-01 09:50:58 +01:00
|
|
|
|
.DESCRIPTION
|
2023-01-23 14:04:23 +01:00
|
|
|
|
This PowerShell script queries PowerShell details and lists it.
|
2022-12-01 09:50:58 +01:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> ./check-powershell
|
2023-04-11 10:26:05 +02:00
|
|
|
|
✅ PowerShell 5.1.19041.2673 Desktop edition (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-11 10:26:05 +02:00
|
|
|
|
$Reply = "✅ PowerShell $Version $Edition edition ($NumModules modules, $NumAliases aliases)"
|
2022-12-04 10:11:52 +01:00
|
|
|
|
} else {
|
|
|
|
|
$NumCmdlets = (Get-Command -Command-Type cmdlet).Count
|
2023-04-11 10:26:05 +02:00
|
|
|
|
$Reply = "✅ PowerShell $Version $Edition edition ($NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)"
|
2022-12-04 10:11:52 +01:00
|
|
|
|
}
|
2023-01-23 14:04:23 +01:00
|
|
|
|
Write-Host $Reply
|
2022-12-01 09:50:58 +01:00
|
|
|
|
exit 0 # success
|
|
|
|
|
} catch {
|
|
|
|
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
|
|
|
|
exit 1
|
2023-01-01 19:22:35 +01:00
|
|
|
|
}
|