PowerShell Script to Find Physical Servers in a VMware Environment

A quick script to find physical Windows servers in a VMware environment.

Filters AD Computer objects by those containing “Server” in the OperatingSystem field, and then queries each machine with WMI to extract the manufacturer. This string is checked to see if it contains “VMware”, and if it doesn’t, it is deemed a physical server. Results are written to a text file.

The “VMware” string could be modified to reflect your hypervisor vendor if it’s not VMware, or multiple vendors if in a mixed vendor virtualisation environment.

$servers = Get-ADComputer -Filter{operatingsystem -like "*Server*"}

foreach($server in $servers)
    $serverinfo = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $server.Name -Credential $Credential
    $manufacturer = $serverinfo.Manufacturer

        $servername = $server.Name
        Add-Content C:\temp\physical_servers.txt "$servername"

Leave a Reply

Your email address will not be published. Required fields are marked *