How to check my windows server is virtual machine or physical machine

后端 未结 8 1259
谎友^
谎友^ 2020-12-31 09:45

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,

相关标签:
8条回答
  • 2020-12-31 09:48

    There is no easy way to tell if you're running in a bare metal or in a virtual computer, the best thing you can do is to get some hardware info and made an educated guess, for example, if the machine have a network adapter which contains Microsoft, VMware, Oracle, Hyper-V, Virtual or VirtualBox, most likely it's a virtual machine given that neither Microsoft, Oracle, or VMware fabricate network cards.

    As you use C#, the class for retrieving this and other hardware info is ManagementClass, also there is this nice project that let you retrieve tons of info from your computer using ManagementClass.

    0 讨论(0)
  • 2020-12-31 09:51

    As far as I know there is no easy way to do this.

    There are a few workarounds but there is, at least as far as I know, not a one-size-fits-all solution.

    Ben Armstrong wrote a post about Detecting Microsoft virtual machines and there's a low-level trick which can determine whether you are running within a Virtual PC or VMWare but that still leaves out VirtualBox and others.

    A trick you might want to try is to detect whether VMWare Tools or VirtualBox Tools are installed. In most cases they are installed on the guest OS to provide needed features but it will be hard to maintain the different installation GUIDS on your end so it's not an ideal solution.

    --- Also , if the VM is running in a Linux KVM environment, the output is like this one enter image description here

    0 讨论(0)
  • 2020-12-31 09:54

    The only *programmatic* way I know of doing this reliably is:

    1. Write an app that crawls your network (or IP range) to get a list of machines.
    2. Display those machines to a person and ask them to check a box if it's a VM...
    3. Print the report.
    0 讨论(0)
  • 2020-12-31 09:55

    Run the systeminfo command @ command prompt see the system menufacturer n system model details. There you can find the virtule and physical machine information.

    0 讨论(0)
  • 2020-12-31 09:56

    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"
    
    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 : .....
    ....
    
    0 讨论(0)
  • 2020-12-31 09:56

    you can use this command in cmd or powershell

    SYSTEMINFO

    You will find a line with the following text (or similar):

    System Manufacturer: VMware, Inc. System Model: VMware Virtual Platform

    0 讨论(0)
提交回复
热议问题