Update check-os.ps1 and check-powershell.ps1

This commit is contained in:
Markus Fleschutz 2023-04-11 10:26:05 +02:00
parent dd2d9e000b
commit 094fca2665
2 changed files with 8 additions and 6 deletions

View File

@ -5,6 +5,7 @@
This PowerShell script queries and lists operating system details. This PowerShell script queries and lists operating system details.
.EXAMPLE .EXAMPLE
PS> ./check-os PS> ./check-os
Windows 10 Pro 64-bit (v10.0.19045, since 6/22/2021, S/N 00123-45678-15135-AAOEM, P/K AB123-CD456-EF789-GH000-WFR6P)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -14,8 +15,8 @@
try { try {
if ($IsLinux) { if ($IsLinux) {
$Name = $PSVersionTable.OS $Name = $PSVersionTable.OS
if ([System.Environment]::Is64BitOperatingSystem) { $Bits = "64-bit" } else { $Bits = "32-bit" } if ([System.Environment]::Is64BitOperatingSystem) { $Arch = "64-bit" } else { $Arch = "32-bit" }
Write-Host "$Name ($Bits)" Write-Host "$Name $Arch"
} else { } else {
$OS = Get-WmiObject -class Win32_OperatingSystem $OS = Get-WmiObject -class Win32_OperatingSystem
$Name = $OS.Caption -Replace "Microsoft Windows","Windows" $Name = $OS.Caption -Replace "Microsoft Windows","Windows"
@ -29,7 +30,7 @@ try {
$InstallDate = $OSDetails.InstallDate $InstallDate = $OSDetails.InstallDate
$ProductKey = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" -Name BackupProductKeyDefault).BackupProductKeyDefault $ProductKey = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" -Name BackupProductKeyDefault).BackupProductKeyDefault
Write-Host "$Name ($Arch, v$Version, S/N $Serial, P/K $ProductKey) since $($InstallDate.ToShortDateString())" Write-Host "$Name $Arch (v$Version, since $($InstallDate.ToShortDateString()), S/N $Serial, P/K $ProductKey)"
} }
exit 0 # success exit 0 # success
} catch { } catch {

View File

@ -1,10 +1,11 @@
<# <#
.SYNOPSIS .SYNOPSIS
Check the PowerShell Check PowerShell details
.DESCRIPTION .DESCRIPTION
This PowerShell script queries PowerShell details and lists it. This PowerShell script queries PowerShell details and lists it.
.EXAMPLE .EXAMPLE
PS> ./check-powershell PS> ./check-powershell
PowerShell 5.1.19041.2673 Desktop edition (10 modules, 1458 cmdlets, 172 aliases)
.LINK .LINK
https://github.com/fleschutz/PowerShell https://github.com/fleschutz/PowerShell
.NOTES .NOTES
@ -17,10 +18,10 @@ try {
$NumModules = (Get-Module).Count $NumModules = (Get-Module).Count
$NumAliases = (Get-Alias).Count $NumAliases = (Get-Alias).Count
if ($IsLinux) { if ($IsLinux) {
$Reply = "✅ PowerShell $Version ($Edition edition, $NumModules modules, $NumAliases aliases)" $Reply = "✅ PowerShell $Version $Edition edition ($NumModules modules, $NumAliases aliases)"
} else { } else {
$NumCmdlets = (Get-Command -Command-Type cmdlet).Count $NumCmdlets = (Get-Command -Command-Type cmdlet).Count
$Reply = "✅ PowerShell $Version ($Edition edition, $NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)" $Reply = "✅ PowerShell $Version $Edition edition ($NumModules modules, $NumCmdlets cmdlets, $NumAliases aliases)"
} }
Write-Host $Reply Write-Host $Reply
exit 0 # success exit 0 # success