I am trying to gather Serial Numbers, Install Dates, and Servers name for a
list of servers in my production environment. I have run into several snags
and I need help!
1) The wmi query to gather the information above is in two different
classes. So for each server I need to be able to query the win32_bios, and
win32_OperatingSystems classes.
2) I need to be able to merge the data into one table and output to a csv
file.
3) In my script I need to be able to use an array or variable so my for each
loop will take input from a txt file. (servers.txt)
So far I have not been very successful on any attempt. I was able to do one
call at a time but have not been able to get anything else to work. This
will not cut it for me because I need to query 530 servers.
Any help would be appreciated.
Thanks,
Alan
$computers = Get-Content Servers.txt
Out-File Servers.csv -inputObject "Name, SN, Install"
foreach ($computer in $computers) {
$winBios = Get-WMIObject Win32_Bios -Computer $computer
$winOS = Get-WMIObject Win32_OperatingSystem
$sn = $winBios.SerialNumber
$install = $winOS.InstallDate
Out-File Servers.csv -inputObject "$computer, $sn, $install" -noClobber
}
-= IJuan =-
gc servers.txt | % {out-file servers.csv -inputobject ("$_, " + (gwmi
Win32_Bios -computer $_).SerialNumber + ", " + (gwmi Win32_OperatingSystem
-computer $_).InstallDate)}
By the way I haven't tested either of these so there may be some typo or
type mismatch errors. Hope they at least get you pointed in the right way.
-= IJuan =-