PowerShell/Scripts/check-powershell.ps1

31 lines
922 B
PowerShell
Raw Normal View History

2022-12-01 09:50:58 +01:00
<#
.SYNOPSIS
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
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
$NumModules = (Get-Module).Count
$NumAliases = (Get-Alias).Count
2022-12-04 10:11:52 +01:00
if ($IsLinux) {
$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
$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
}