Omz*_*zig 4 powershell powershell-2.0
本文档解释了如何获取Windows版本,但在PowerShell中找到它更难.
[System.Environment]::OSVersion
有很多好的信息但不是服务器工作站标志......
bri*_*ist 13
$osInfo = Get-CimInstance -ClassName Win32_OperatingSystem
$osInfo.ProductType
Run Code Online (Sandbox Code Playgroud)
请参阅https://msdn.microsoft.com/en-us/library/aa394239%28v=vs.85%29.aspx
Run Code Online (Sandbox Code Playgroud)ProductType Data type: uint32 Access type: Read-only Additional system information. Work Station (1) Domain Controller (2) Server (3)
因此,如果值是1
,那么您在工作站操作系统上.
如果是2
你在域控制器上.
如果它3
是在不是域控制器的服务器上.
如果您使用的是旧版本的Windows/PowerShell并希望能够在所有这些版本中运行,那么它们是相同的,但是Get-WmiObject
:
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
$osInfo.ProductType
Run Code Online (Sandbox Code Playgroud)
(Get-ComputerInfo).OsProductType
Run Code Online (Sandbox Code Playgroud)
在我的机器上,这会返回WorkStation
或Server
。
归档时间: |
|
查看次数: |
4292 次 |
最近记录: |