Many a times we need to check whether a server is physical, virtual, or on Cloud. we can get the details by checking the manufacturer of the server from the systeminfo, but if you want to check the details for a list of servers it becomes a tedious task.
Here we came up with a PowerShell script that queries the Win32_Computersystem WMI Class of that server and gets the manufacturer details in a CSV file.
Please find below the Powershell script which fetches the Manufacturer details for a list of servers provided in a text file as an input and gives the CSV file with the details in the output.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Results = @() | |
$servers = Get-Content C:\Script\list.txt | |
foreach($server in $servers) | |
{ | |
Try | |
{ | |
$Manufacturer = Get-WmiObject WIn32_computerSystem -ComputerName $server -ErrorAction Stop | Select -ExpandProperty Manufacturer | |
} | |
Catch | |
{ | |
$Manufacturer = "Server not reachable or not Windows Server" | |
} | |
$Properties = @{ | |
ServerName = $server | |
Manufacturer = $Manufacturer | |
} | |
$Results += New-Object psobject -Property $Properties | |
} | |
$Results | Select-Object ServerName,Manufacturer | Export-Csv C:\Script\Detaiils.csv -NoTypeInformation |
0 comments:
Post a Comment