Powershell script to get server specifications

Here is the usefull script that will get you server specifications like Server FQDN, Physical or Virtual info, Model, Total Memory, Bios Version, IP and MAC addresses, Subnet mask, Default Gateway, DHCP status, OS type, Service Pack, Serial Number etc.

Create a servers.txt file with the list of servers for which you want to get the server specifications. One server per line.


serverslist.txt example:


Now create a new text file and rename it to serverlist.ps1

$Excel = New-Object -Com Excel.Application
$Excel.visible = $True
$Excel = $Excel.Workbooks.Add()
# Insert text in to first row.
$Sheet = $Excel.WorkSheets.Item(1)
$Sheet.Cells.Item(1,1) = "Server"
$Sheet.Cells.Item(1,2) = "FQDNName"
$Sheet.Cells.Item(1,3) = "Manufacturer"
$Sheet.Cells.Item(1,4) = "Model"
$Sheet.Cells.Item(1,5) = "TotalPhysicalMemory"
$Sheet.Cells.Item(1,6) = "isVirtual"
$Sheet.Cells.Item(1,7) = "SerialNumber"
$Sheet.Cells.Item(1,8) = "Bios Version"
$Sheet.Cells.Item(1,9) = "IP Address"
$Sheet.Cells.Item(1,10) = "MAC Address"
$Sheet.Cells.Item(1,11) = "IPSubnet"
$Sheet.Cells.Item(1,12) = "DefaultGateway"
$Sheet.Cells.Item(1,13) = "Type"
$Sheet.Cells.Item(1,13) = "DHCPEnabled"
$Sheet.Cells.item(1,17) = "OperatingSystem"
$Sheet.Cells.Item(1,18) = "ServicePack"
$Sheet.Cells.item(1,19) = "BuildNumber"
$Sheet.Cells.Item(1,20) = "BuildType"
$Sheet.Cells.Item(1,21) = "Version"
$Sheet.Cells.Item(1,22) = "SerialNumberOS"
# Format colors.
$WorkBook = $Sheet.UsedRange
$WorkBook.Interior.ColorIndex = 15
$WorkBook.Font.Bold = $True
# Go to the second row.
$intRow = 2
# Select text file which contains list of servers to query.
$arrComputers = GC C:\temp\serverslist.txt
# Get currently logged in username, client name, manufacturer and model from Win32_ComputerSystem class.
foreach ($strComputer in $arrComputers){
try { $colItems = Get-WmiObject Win32_ComputerSystem -Namespace "root\CIMV2" -ErrorAction stop -ComputerName $strComputer
foreach($objItem in $colItems) {
$Sheet.Cells.Item($intRow,1) = $objItem.Name
$Sheet.Cells.Item($intRow,2) = ($objItem | % {$_.DNSHOSTName +'.'+$_.domain}).ToLower()
$Sheet.Cells.Item($intRow,3) = $objItem.Manufacturer
$Sheet.Cells.Item($intRow,4) = $objItem.Model
$Sheet.Cells.Item($intRow,5) = ($objItem.TotalPhysicalMemory/1024MB)
if($objItem.Model -like "VMWare*")
$Sheet.Cells.Item($intRow,6) = "Yes"
# Get workstation serial number from Win32_BIOS class.
$colItems = Get-WmiObject Win32_BIOS -Namespace "root\CIMV2" -ErrorAction stop -ComputerName $strComputer
foreach($objItem in $colItems) {
$Sheet.Cells.Item($intRow,7) = $objItem.SerialNumber
if($objItem.BiosVersion -eq $null)
$Sheet.Cells.Item($intRow,8)= "Unknown"
$Sheet.Cells.Item($intRow,8) = $objItem.BiosVersion[0]
#Get OperatingSystme Imforamtion from Win32_OperatingSystem
$colItems = Get-WmiObject Win32_OperatingSystem -Namespace "root\CIMV2" -ErrorAction stop -ComputerName $strComputer
foreach($objItem in $colItems) {
$Sheet.Cells.Item($intRow,17) = $objItem.Name | % { $_.Split("|")[0] }
$Sheet.Cells.Item($intRow,18) = $objItem.servicepackmajorversion
$Sheet.Cells.Item($intRow,19) = $objItem.BuildNumber
$Sheet.Cells.Item($intRow,20) = $objItem.BuildType
$Sheet.Cells.Item($intRow,21) = $objItem.Version
$Sheet.Cells.Item($intRow,22) = $objItem.SerialNumber
# Get IP address and MAC address of the enabled network adapter from Win32_NetworkAdapaterConfiguration class.
$colItems = Get-WmiObject Win32_NetworkAdapterConfiguration -Namespace "root\CIMV2" -ErrorAction stop -ComputerName $strComputer | where{$_.IPEnabled -eq “$true”}
foreach($objItem in $colItems) {
$Sheet.Cells.Item($intRow,9) = $objItem.IPAddress[0]
$Sheet.Cells.Item($intRow,10) = $objItem.MACAddress
$Sheet.Cells.Item($intRow,11) = $objItem.IPSubnet
$Sheet.Cells.Item($intRow,12) = $objItem.DefaultIPGateway
$Sheet.Cells.Item($intRow,13) = "IPv4"
$Sheet.Cells.Item($intRow,14) = $objItem.DHCPEnabled
catch {
Write-Host "Could not contact $($strComputer)" -ForegroundColor Red
Out-File -FilePath C:\Noreach.txt -InputObject $strComputer -Append -Force

Save the script to the same folder at C:\temp.

Before you’ll be able to run the script you will have to enable execution policy on your system (if you haven’t already):

Start the Powershell in elevated mode (Run as Administrator) and run the following command:

Set-ExecutionPolicy RemoteSigned

Now run the Powershell script by using this command:

powershell -noexit “& “”C:\temp\serverlist.ps1″””

server specifications

You should get server specifications results on your screen.

You may also like...

Leave a Reply

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

19 + 19 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.