mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-05-29 06:37:50 +02:00
Update check-operating-system.ps1
This commit is contained in:
parent
c5e2f92a4c
commit
9f396620df
@ -1,8 +1,8 @@
|
|||||||
<#
|
<#
|
||||||
.SYNOPSIS
|
.SYNOPSIS
|
||||||
Determines the exact OS version
|
Query OS details
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
This PowerShell script determines and lists the exact operating system version.
|
This PowerShell script queries and lists operating system details.
|
||||||
.EXAMPLE
|
.EXAMPLE
|
||||||
PS> ./check-operating-system
|
PS> ./check-operating-system
|
||||||
.LINK
|
.LINK
|
||||||
@ -13,21 +13,20 @@
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if ($IsLinux) {
|
if ($IsLinux) {
|
||||||
$Summary = (uname -sr)
|
"✅ $(uname -sr)."
|
||||||
} else {
|
} else {
|
||||||
[system.threading.thread]::currentthread.currentculture = [system.globalization.cultureinfo]"en-US"
|
|
||||||
$OS = Get-WmiObject -class Win32_OperatingSystem
|
$OS = Get-WmiObject -class Win32_OperatingSystem
|
||||||
$Name = $OS.Caption
|
$Name = $OS.Caption
|
||||||
$Architecture = $OS.OSArchitecture
|
$Architecture = $OS.OSArchitecture
|
||||||
$Version = $OS.Version
|
$Version = $OS.Version
|
||||||
|
|
||||||
$OSDetails = Get-CimInstance Win32_OperatingSystem
|
[system.threading.thread]::currentthread.currentculture = [system.globalization.cultureinfo]"en-US"
|
||||||
$InstallDate = $OSDetails.InstallDate
|
$OSDetails = Get-CimInstance Win32_OperatingSystem
|
||||||
$Summary = "$Name for $Architecture v$Version, installed on $($InstallDate.ToShortDateString())"
|
$InstallDate = $OSDetails.InstallDate
|
||||||
|
"✅ $Name ($Architecture) v$Version, installed $($InstallDate.ToShortDateString())"
|
||||||
}
|
}
|
||||||
"✅ Running $Summary."
|
|
||||||
exit 0 # success
|
exit 0 # success
|
||||||
} catch {
|
} catch {
|
||||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user