在不使用 WMI 的情况下获取操作系统 [英] Get operating system without using WMI

查看:31
本文介绍了在不使用 WMI 的情况下获取操作系统的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Powershell 脚本,我需要在其中获取各种服务器的操作系统.到目前为止,我一直在使用 WMI 来完成这项任务,但是我已经阅读了有关 WMI 如何获得超时的信息,所以我想知道是否有另一种获取服务器操作系统的方法?这是我目前使用的代码,为了避免 WMI 想要更改:

I have a Powershell script where I need to get the operating system for various servers. Up until now I've been using WMI in order to accomplish this task, however I've read about how WMI can get timeouts, so I was wondering is there another method of getting the operating system of a server? Here is the code that I use at the moment and want to change in order to avoid WMI:

$serverVersion = Get-WMIObject -computer $server -class Win32_OperatingSystem

推荐答案

您可能会在注册表中找到您要查找的内容.从 Windows 2000 开始,可以在以下位置找到 ProductName 值:HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion.

You will probably find what you are looking for in the registry. As of Windows 2000 the ProductName value can be found in this location: HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion.

要使用 Powershell 查询此注册表值,请尝试:

To query this registry value using Powershell, try:

(get-itemproperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ProductName).ProductName

这篇关于在不使用 WMI 的情况下获取操作系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆