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.
.EXAMPLE
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
https://github.com/fleschutz/PowerShell
.NOTES
@ -14,8 +15,8 @@
try {
if ($IsLinux) {
$Name = $PSVersionTable.OS
if ([System.Environment]::Is64BitOperatingSystem) { $Bits = "64-bit" } else { $Bits = "32-bit" }
Write-Host "$Name ($Bits)"
if ([System.Environment]::Is64BitOperatingSystem) { $Arch = "64-bit" } else { $Arch = "32-bit" }
Write-Host "$Name $Arch"
} else {
$OS = Get-WmiObject -class Win32_OperatingSystem
$Name = $OS.Caption -Replace "Microsoft Windows","Windows"
@ -29,7 +30,7 @@ try {
$InstallDate = $OSDetails.InstallDate
$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
} catch {

View File

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