如何检查我的Windows服务器是虚拟机或物理机 [英] How to check my windows server is virtual machine or physical machine

查看:1350
本文介绍了如何检查我的Windows服务器是虚拟机或物理机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我远程访问桌面到Windows服务器在我们的实验室/数据中心。我有一个要求,要弄清楚我们所有的服务器都虚拟机或物理服务器编程,当然我们有环境表告诉我们哪个是哪个。但我需要编写代码来区分。我需要什么技术使用?我没有找到一个.NET程序集来做到这一点。寻找专家来分享你的知识和指导,任何研究方向或链接任何将不胜感激!

I'm remoting desktop to windows servers in our Lab/datacenter. I have a requirement to figure out all our servers are virtual machines or physical servers programatically, certainly we have the environment sheet tell us which is which. But I need to write code to distinguish it. What technique I need to use? I didn't find a .Net Assembly to do that. Looking for expert to share your knowledge or guidance, any research direction or link, anything will be appreciated!

推荐答案

您可以尝试使用下面的PowerShell脚本,它利用WMI来看看机器是虚拟机或物理机。

You can try to use the following PowerShell script, it utilizes WMI to find out if machine is virtual machine or physical machine.


gwmi -q "select * from win32_computersystem"


当然,你可以使用C#代码来查询WMI了。脚本的输出上面会像下面这样:

Certainly, you can use C# code to query WMI too. The output of script above will be like following:


Domain:   ...
Manufacturer: Microsoft Corporation
Model: Virtual Machine
Name : .....
....

这篇关于如何检查我的Windows服务器是虚拟机或物理机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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