77 lines
2.7 KiB
PowerShell
77 lines
2.7 KiB
PowerShell
function readOsInfoConfig{param([string]$Path)
|
|
Invoke-Expression "[ordered]@{`n$(cat $Path|% { $_ -replace '=([^"''].*[^"''])$','="$1"' }|out-string)}"
|
|
}
|
|
|
|
$local:osInfo = [ordered]@{
|
|
Icon =
|
|
Name = ""
|
|
OS = [Environment]::OSVersion.VersionString -replace 'Windows NT 10','Windows 10'
|
|
VER = [Environment]::OSVersion.Version.ToString()
|
|
Platform = [Environment]::OSVersion.Platform
|
|
}
|
|
|
|
if( $osInfo.OS -eq 'Unix' ) {
|
|
if( Test-Path /etc/os-release ) {
|
|
$local:tmpInfo = readOsInfoConfig /etc/os-release
|
|
$osInfo.OS = $tmpInfo.NAME
|
|
$osInfo.VER = $tmpInfo.VERSION_ID
|
|
} elseif( Get-Command lsb_release -ErrorAction Ignore ) {
|
|
$osInfo.OS = & lsb_release -si
|
|
$osInfo.VER = & lsb_release -sr
|
|
} elseif( Test-Path /etc/lsb-release ) {
|
|
$local:tmpInfo = readOsInfoConfig /etc/os-release
|
|
$osInfo.OS = $tmpInfo.DISTRIB_ID
|
|
$osInfo.VER = $tmpInfo.DISTRIB_RELEASE
|
|
} elseif( Test-Path /etc/debian_version ) {
|
|
$osInfo.OS = "Debian"
|
|
$osInfo.VER = Get-Content /etc/debian_version
|
|
} elseif( Test-Path /etc/SuSe-release ) {
|
|
#readOsInfoConfig /etc/SuSe-release
|
|
$osInfo.OS = ""
|
|
$osInfo.VER = ""
|
|
} elseif( Test-Path /etc/redhat-release ) {
|
|
#readOsInfoConfig /etc/redhat-release
|
|
$osInfo.OS = ""
|
|
$osInfo.VER = ""
|
|
} else {
|
|
$osInfo.OS = $(unmae -s)
|
|
$osInfo.VER = $(unmae -r)
|
|
}
|
|
} elseif( $osInfo.OS -ne "MacOSX" ) {
|
|
$osInfo.OS = {
|
|
if($osInfo.OS -match "Windows 10")
|
|
{
|
|
switch ($buildnumber)
|
|
{
|
|
10240 {"Win10 1507"}
|
|
10586 {"Win10 1511"}
|
|
14393 {"Win10 1607"}
|
|
15063 {"Win10 1703"}
|
|
16299 {"Win10 1709"}
|
|
17134 {"Win10 1803"}
|
|
17763 {"Win10 1809"}
|
|
18362 {"Win10 1903"}
|
|
18363 {"Win10 1909"}
|
|
19041 {"Win10 20H1"}
|
|
19042 {"Win10 20H2"}
|
|
19043 {"Win10 21H1"}
|
|
default {"Unkown Win10"}
|
|
}
|
|
} elseif ($osInfo.OS -match "Windows Server")
|
|
{
|
|
switch ($buildnumber)
|
|
{
|
|
3790 {$OS = "Windows Server 2003 R2"}
|
|
6001 {$OS = "Windows Server 2008"}
|
|
7600 {$OS = "Windows Server 2008 SP1"}
|
|
7601 {$OS = "Windows Server 2008 R2"}
|
|
9200 {$OS = "Windows Server 2012"}
|
|
9600 {$OS = "Windows Server 2012 R2"}
|
|
14393 {$OS = "Windows Server 2016"}
|
|
17763 {$OS = "Windows Server 2019"}
|
|
}
|
|
}
|
|
Write-Host "Server system: $OS | $osversion | $buildnumber" -foregroundcolor Green
|
|
|
|
|
|
} |