For most IT system administrators, having information about remote computers via scripting is a must. Today we will learn how to retrieve hard drive serial number from a remote computer in an active directory network. The following commands must be run on a computer with domain administrator privileges.
Get remote disks
<# Retrieve hard drives remotely (replace remoteComputer) #>
$hardDrives = Get-WMIObject -class win32_PhysicalMedia -computername remoteComputer
We now have a variable ($hardDrives) with a list of all hard drives on remoteComputer
Retrieve hard drive serial numbers
If remoteComputer have more than one hard drive, you need to create a loop to iterate through all hard drives and list serial numbers as follow :
foreach($disk in $disks)
Now you can do whatever you want with that serial number, you can also export results in a .CSV file. Another thing you can do is create a list of active computers and then loop through all computers to get serial numbers of all disks. This is pretty useful for inventory.