Quantcast
Channel: windows server – VM.Blog.
Viewing all articles
Browse latest Browse all 29

PowerShell script to find a server is physical server or virtual machine

$
0
0

### Powershell script gives Manufacturer and Server Model for a given list of servers, and we can find if its a VM or a physical server.
### eg: for a VM, manufacturer will be “VMware, Inc.”, and model will be “VMware Virtual Platform”
### eg: for a physical server, manufacturer will be “HP” (or others), and model will be “ProLiant BL460c G7”
### Servers which we failed to connect to get any info are collected in to a txt file.
### writing credits : VM ###
#######################################################################################

$servers = Get-Content “D:\temp\test2.txt”
$result = @()
$finalresult = @()

foreach ($computer in $servers)
{
$result = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer | select pscomputername, manufacturer, model
$finalresult+=$result
if (!$result) { Write “No info on server $computer” | out-file -Append “D:\temp\notfound-phy-vm.txt” -NoClobber }
$computer = $null
$result = $null
}

$finalresult | export-csv “D:\temp\VMphys-1.csv” -NoTypeInformation


Viewing all articles
Browse latest Browse all 29

Trending Articles