Simply get computer name with serial number

Hi All,

I use the script below to get serial number, but I have no idea how to get the computer name in the meantime.

Pls point me.

$File = [System.IO.File]::OpenText("d:\111.txt")
 while($Machine = $GuyFile.ReadLine())
{Get-WmiObject -computername $Machine win32_SystemEnclosure }
$GuyFile.Close()

August 6th, 2012 12:53pm

$machine is computername so just

echo $machine


  • Edited by Blindrood Monday, August 06, 2012 10:06 AM
Free Windows Admin Tool Kit Click here and download it now
August 6th, 2012 1:06pm

gwmi win32_SystemEnclosure | select  __server,serialnumber

August 6th, 2012 4:22pm

Dear Both, Thanks so much.
Free Windows Admin Tool Kit Click here and download it now
August 7th, 2012 4:21am

By the way, how can I get Harddisk size and memory and then export to the csv file.

Thanks.

August 7th, 2012 4:28am

$drives = gwmi -Class win32_logicaldisk | select deviceid, size
$memory = gwmi -Class win32_computersystem | select totalphysicalmemory

Free Windows Admin Tool Kit Click here and download it now
August 7th, 2012 9:35am

Get-WmiObject -Class Win32_BIOS -Filter 'SerialNumber="SN"' | Select -Property PSComputerName

Replace SN with your serial number for testing
August 29th, 2013 4:13pm

Hi,

I run this command from PS:

Get-WmiObject -Class Win32_BIOS -Filter 'SerialNumber="SN"' | Select -Property PSComputerName

But result is nothing. Please help.

I have list of Serial Numbers and target is to get Computer Names (inventory, remote).

Free Windows Admin Tool Kit Click here and download it now
February 6th, 2015 1:12pm

Hello Andrejs,

Try this, May be the formatting would be little off.. but you shud get the results.

function Get-ServerInfo {
PROCESS {
$computername = $_
$data = Get-WmiObject -class Win32_logicalDisk -ComputerName localhost | Select PSComputerName, DeviceID,@{n='Size(GB)';e={$_.size / 1gb -as [int]}},@{n='Free(GB)';e={$_.Freespace / 1gb -as [int]}}
$bios = Get-WMIObject -Class Win32_BIOS
$value = $data + $bios
$value | select PSComputerName, DeviceID,SerialNumber,'Size(GB)','Free(GB)'

  }
}
Get-Content c:\servers.txt | Get-ServerInfo | Format-Table -auto

It generates, computername, Drives , Size of drives, free space (in GB), serial number

put your server list in c:\servers.txt

Regards,

Venu

February 6th, 2015 3:33pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics