我正在使用Windows Server 2016 nano的最新预览版。
使用远程PowerShell会话,我通过Enter-PSSession连接到远程系统,然后尝试使用最常用的技术来检查Windows版本,因为完整的.Net框架不可用。 另外,Get-WmiObject cmdlet不可用。
我可以看到一些信息的唯一方法就是使用这个非powershell命令DISM:
Dism /Online /Get-Feature
这给了我这个输出以及一个安装的function列表:
Deployment Image Servicing and Management tool Version: 10.0.10514.0 Image Version: 10.0.10514.0 Features listing for package : Microsoft-Windows-Foundation-Package~31bf3856ad364e35~amd64~~10.0.10514.0
从10514的值比我的Windows 10桌面高,我可以对内核构build有一些了解,有趣的是,Windows 10桌面具有相同的“Microsoft-Windows-Foundation-Package”,但是较低的内核构build数。
有没有人发现一个cmdlet或一些PowerShellfunction或别名,可以写,这将检测到我的PowerShell脚本运行在纳米服务器,以某种方式不可能中断,或任何命令将其实打印出“Windows Server 2016纳米服务器”?
更新:这更接近我想要的,但有点破解:
Get-Item -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion'
更新2:Get-WmiObject不存在,虽然下面的工作,它只报告内核版本:
[System.Environment]::OSVersion.Version
上面将报告构build10514,而Windows 10客户端操作系统RTM报告10240目前,但上述是真正的“内核构build”而不是操作系统产品/版本/服务包级别。
你可以尝试以下,我还没有一个纳米服务器来尝试。 删除select如果它得到你的东西,看看你想要的东西存储在服务器2016年纳米不同的属性
Get-CIMInstance -ClassName Win32_OperatingSystem -Property * | select caption
当在真实的Nano实例上testing时,不需要-session参数,但是如果在将来某个date需要它,以下是带有-session的变体:
$cuser = "Your username" $cservername = "Your Servername" $csession = New-CimSession –Credential $cuser –ComputerName $cservername Get-CIMInstance –session $csession -ClassName Win32_OperatingSystem -Property * | select caption
这只是编辑中的扩展,但通过获取ProductName来清理输出
$(Get-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion' ProductName).ProductName