小编P V*_*ota的帖子

确定 Windows 是托管在物理机还是虚拟机上?#电源外壳

我正在尝试查找 Windows 操作系统是否托管在物理机或虚拟机上。

互联网上有一段 powershell 脚本片段,我在其中添加了一些条件来确定机器是否托管在云上(那么它可能是虚拟机)。


function GetMachineType {
    $ComputerSystemInfo = Get-WmiObject -Class Win32_ComputerSystem
    switch ($ComputerSystemInfo.Model) { 

        # Check for VMware Machine Type 
        "VMware Virtual Platform" { 
            Write-Output "This Machine is Virtual on VMware Virtual Platform."
            Break 
        } 

        # Check for Oracle VM Machine Type 
        "VirtualBox" { 
            Write-Output "This Machine is Virtual on Oracle VM Platform."
            Break 
        } 
        default { 

            switch ($ComputerSystemInfo.Manufacturer) {

                # Check for Xen VM Machine Type
                "Xen" {
                    Write-Output "This Machine is Virtual on Xen Platform" …
Run Code Online (Sandbox Code Playgroud)

windows powershell virtualization virtual-machine

5
推荐指数
1
解决办法
1万
查看次数