This doc explains how to get your windows version, but to find it in PowerShell is harder.
[System.Environment]::OSVersion has a lot of good info but not the Server-Workstation Flag...
This doc explains how to get your windows version, but to find it in PowerShell is harder.
[System.Environment]::OSVersion has a lot of good info but not the Server-Workstation Flag...
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem $osInfo.ProductType See https://msdn.microsoft.com/en-us/library/aa394239%28v=vs.85%29.aspx
ProductType Data type: uint32 Access type: Read-only Additional system information. Work Station (1) Domain Controller (2) Server (3)
So if the value is 1, then you are on a workstation OS.
If it's 2 you're on a domain controller.
If it's 3 you're on a server that is not a domain controller.
If you're on an old version of Windows / PowerShell and want something that will work across all of them, it's the same, but with Get-WmiObject:
$osInfo = Get-WmiObject -Class Win32_OperatingSystem $osInfo.ProductType Get-CimInstance must be a cmdlet not available on the Win7 version of powershell?Get-CmiInstance -ClassName and Get-WmiObject -Class distiction -- thanks.Get-CmiObject and Get-WmiObject capable. Thank you.(Get-ComputerInfo).OsProductType On my machines this returned either WorkStation or Server.
Get-ComputerInfo isn't available prior to PowerShell v5.1.Get-ComputerInfo -Property OsProductType) doesn't speed things up. (b) A progress bar is invariably shown during execution.$osType = Try { Get-CIMInstance -Classname Win32_OperatingSystem -ErrorAction Stop | Select -expand ProductType } Catch { Get-WMIObject -Classname Win32_OperatingSystem -ErrorAction Stop | Select -Expand ProductType } Switch ($osType) { 1 {"Workstation"} 2 {"Domain Controller"} 3 {"Member Server"} }