If you are authoring scripts targeting Nano server specifically then there are two checks which you can bake into (maybe add them to the default nano authoring snippet in ISE) them.
Query the Win32_OperatingSystem CIM class and check if the property named 'OperatingSystemSKU' is 143 (Datacenter) or 144 (Standard). As per the MSFT documentation for the CIM class :
Check the Operating System SKU
Query the Win32_OperatingSystem CIM class and check if the property named 'OperatingSystemSKU' is 143 (Datacenter) or 144 (Standard). As per the MSFT documentation for the CIM class :
PRODUCT_DATACENTER_NANO_SERVER (143)
Windows Server Datacenter Edition (Nano Server installation)
Windows Server Standard Edition (Nano Server installation)
Something like below, you can be more creative with it :
001
002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 |
#region Nano server check
Switch -Exact ($(Get-CimInstance -ClassName Win32_OperatingSystem).OperatingSystemSKU) { 143 { Write-Verbose -Message 'Script Running on Windows Server Datacenter Edition (Nano Server installation)' break; } 144 { Write-Verbose -Message 'Windows Server Standard Edition (Nano Server installation)' break; } default { Write-Warning -Message 'OperatingSystem SKU does not match Nano server.' throw } } #enderegion |