Link to home
Start Free TrialLog in
Avatar of Jorge Ocampo
Jorge OcampoFlag for United States of America

asked on

Dell and HP Serial Number/Service Tag

how do i command line into the boxes and retrieve hardware information and service tag number/serial number

i have access to the box just have many rather do them from my laptop
Avatar of David Carr
David Carr
Flag of United States of America image

Go to Start then Run and type cmd to start your command prompt.

type wmic csproduct get vendor,name,identifyingnumber


 and to save it in a text file add > c:\servicetag.txt to the end of the above line
Avatar of Jorge Ocampo

ASKER

but that would have to be done on the actual server what about remote cmd?
Jorge,

What David said should work even if you remote into each computer. Just remote into each one, run the CMD, and type the command that David specified (wmic csproduct get vendor,name,identifyingnumber). And as David specified if you want to create a text file so you don't have to copy the information from the CMD prompt, just do the following:

wmic csproduct get vendor,name,identifyingnumber > c:\hardwareinfo.txt

Where "c:\hardwareinfo.txt" can be any path you choose and any file name you would like to have. If they are all within the same network and you have a shared network drive you can specify that path instead so you can have them all in the same place. But remember to use the Fully Qualified name for the path (\\servername\sharename\filename.txt).

Hope this helps clarify further what David explained.

Any questions just let us know.
yes i got that part guys what i meant is how do i do a remote cmd not rdp into the machine
You can use wmic /user:youraccount /node:ip bios get serialnumber
   You will be prompted for the password for youraccount. Enter remote server's ip  after /node. If you use the remote server's hostname you have to use " around the name. e.g. wmic /user:youraccount /node:"server-name" bios get serialnumber
If you're interested in PowerShell, the equivalent of the wmic command is
Get-WmiObject Win32_ComputerSystemProduct | Select Vendor,Name,IdentifyingNumber

You can loop through a list of computers with
Get-Content computers.txt | ForEach { Get-WmiObject Win32_ComputerSystemProduct -ComputerName $_ } | Select Vendor,Name,IdentifyingNumber

Open in new window

where computers.txt contains a list of the computers you want to query (one name per line).
Or you could get Vendor, Model Name, and Serial/Service Tag for every computer on your network or adjust Get-ADComputer to get what you want.

This will export to a CSV with the computer name as well
$computers = Get-ADComputer -Filter *
foreach ($computer in $computers) { 
Get-WmiObject Win32_ComputerSystemProduct -ComputerName $computer| Select @{Name="Computer Name";Expression={Get-ADComputer $computer | Select Name}},Vendor,Name,IdentifyingNumber | Export-CSV C:\ComputerInfo.csv -nti
}

Open in new window


This will use the list option
$computers = GC C:\computerlist.txt
foreach ($computer in $computers) { 
Get-WmiObject Win32_ComputerSystemProduct -ComputerName $computer| Select @{Name="Computer Name";Expression={Get-ADComputer $computer | Select Name}},Vendor,Name,IdentifyingNumber | Export-CSV C:\ComputerInfo.csv -nti
}

Open in new window

joshua where could i filter the OU that i want it to search through since i only care about servers
You can just add searchbase
$results = @()
$computers = (Get-ADComputer -Filter * -SearchBase "OU=Servers,CN=Computers,DC=yourdomain,DC=com").name
foreach ($computer in $computers) { 
$results += Get-WmiObject Win32_ComputerSystemProduct -ComputerName $computer| Select @{Name="Computer Name";Expression={$computer}},Vendor,Name,IdentifyingNumber
}
$results | Export-CSV C:\ComputerInfo.csv -nti

Open in new window


or you can filter by operating system name (Enabled computers with server in OS name)

$results = @()
$computers = (Get-ADComputer -Filter {Enabled -eq $True -and OperatingSystem -like "*server*"}).name
foreach ($computer in $computers) { 
$results += Get-WmiObject Win32_ComputerSystemProduct -ComputerName $computer| Select @{Name="Computer Name";Expression={$computer}},Vendor,Name,IdentifyingNumber
}
$results | Export-CSV C:\ComputerInfo.csv -nti

Open in new window

can it be so it exports to cvs?
I made a few corrections on my last post and it does export to CSV
@Joshua Grantom - Your examples include some unnecessary lookups and syntax/logic errors.
In the first one the simplest fix would be to modify line 1 to be
$computers = Get-ADComputer -Filter * | Select -expand Name
Then your WMI query will actually work.  Next when you're getting the computer name, there's no reason to do another query to AD, you already have the info (in $computer or could just use the PSComputerName property returned from the WMI query).  Lastly, since you're calling Export-CSV within a loop, you either need to have a unique filename for each loop, or use the -append parameter to avoid repeatedly overwriting the file (available with PS 3.0+).  You could avoid that with having Export-CSV outside a loop (for example by piping from the foreach-object cmdlet).
Get-Content computers.txt | ForEach { Get-WmiObject Win32_ComputerSystemProduct -ComputerName $_ } |
 Select PSComputerName,Vendor,Name,IdentifyingNumber | Export-CSV compinfo.csv -notype

Open in new window


EDIT:  I just saw that you've made some modifications which correct some of what I mentioned.
Hey footech,

Thanks, my second posts made some changes, I realized that I was querying the same thing again as well as the export-csv not being outside the loop
Joshua i see you are not filtering anymore is that right?
ASKER CERTIFIED SOLUTION
Avatar of Joshua Grantom
Joshua Grantom
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It would have been appropriate to accept http:#a40387120 as an assist, as that was the first to give the main PowerShell code for retrieving the info from whatever remote servers you wish.