Test-Is NanoServer speed improvement

Replace Get-ComputerInfo with Registry Value Test
This commit is contained in:
Simon Heather
2019-04-18 12:39:33 +01:00
committed by GitHub
parent 52942260cf
commit 33d408aee4
+8 -15
View File
@@ -8,23 +8,16 @@ function Test-IsNanoServer
[CmdletBinding()]
param ()
$isNanoServer = $false
if (Test-CommandExists -Name 'Get-ComputerInfo')
$ServerLevels = Get-ItemProperty -Path 'HKLM:\Software\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels'
If ($ServerLevels.NanoServer -eq 1)
{
$computerInfo = Get-ComputerInfo -ErrorAction 'SilentlyContinue'
if ($null -ne $computerInfo)
{
$computerIsServer = 'Server' -ieq $computerInfo.OsProductType
if ($computerIsServer)
{
$isNanoServer = 'NanoServer' -ieq $computerInfo.OsServerLevel
}
}
$isNanoServer = $True
}
Else
{
$isNanoServer = $false
}
return $isNanoServer
}