Determine if SQL Server is running on VM

  • Mk.elsawy

    Newbie

    Points: 1

    $Virtual = Get-wmiobject win32_computersystem | Where-Object model -EQ 'Virtual Machine'
    if ($Virtual){
    Write-Host "`nSQL Server Running on Virtual Server" -ForegroundColor Green
    }
    else
    {
    Write-Host "`nSQL Server Running on Physical Server" -ForegroundColor Yellow
    }

    Thanks,
    Mohamed k.elsawy

  • Sue_H

    SSC Guru

    Points: 90194

    The information is available in sys.dm_os_sys_info since SQL Server 2008R2:

    SELECT virtual_machine_type, virtual_machine_type_desc 
    FROM sys.dm_os_sys_info

    Sue

     

     

Viewing 2 posts - 16 through 17 (of 17 total)

You must be logged in to reply to this topic. Login to reply