Determine if SQL Server is running on VM

  • $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

  • 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 16 (of 16 total)

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