![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | WMI calls problem Hello, 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 |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: WMI calls problem Try something like this: $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 =- "Alan" wrote: > Hello, > > 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 |
My System Specs![]() |
| | #3 (permalink) |
| Guest | RE: WMI calls problem Or a oneliner like this. 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 =- "IJuan" wrote: > Try something like this: > > $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 =- > > "Alan" wrote: > > > Hello, > > > > 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 |
My System Specs![]() |
| | #4 (permalink) |
| Guest | RE: WMI calls problem Thank you for both inputs. I will test them on Monday and post my findings. This is exactly what I was looking for! "IJuan" wrote: > Or a oneliner like this. > > 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 =- > > "IJuan" wrote: > > > Try something like this: > > > > $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 =- > > > > "Alan" wrote: > > > > > Hello, > > > > > > 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 |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to make calls from my pc | navybluecross | Vista hardware & devices | 4 | 05-06-2008 08:50 AM |
| video calls | omamelly | Live Messenger | 0 | 04-10-2008 01:50 AM |
| Video Calls Slow.. need help !!!! | Heshan | Live Messenger | 1 | 02-16-2008 08:40 PM |
| Live Messenger Calls | Gabe | Vista General | 0 | 04-11-2007 09:18 AM |
| Belkin Router problem - calls drop with Skype | Steve | Vista networking & sharing | 0 | 03-16-2007 06:51 AM |