Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find out from powershell if I am on a server or workstation?

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...

like image 781
Omzig Avatar asked Feb 02 '18 23:02

Omzig


People also ask

How do you check the status of a service in PowerShell?

To find the service name and display name of each service on your system, type Get-Service . The service names appear in the Name column, and the display names appear in the DisplayName column. When you sort in ascending order by status value, Stopped services appear before Running services.

How do I check system configuration in PowerShell?

Enter the PowerShell system info commandType Get-ComputerInfo and press “Enter”. It will return all of your system specifications, from the Windows version to Bios data.


Video Answer


2 Answers

$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
like image 123
briantist Avatar answered Oct 22 '22 21:10

briantist


(Get-ComputerInfo).OsProductType

On my machines this returned either WorkStation or Server.

like image 42
Kory Gill Avatar answered Oct 22 '22 21:10

Kory Gill