Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

WMI calls problem

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 05-05-2007   #1 (permalink)
Alan
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 SpecsSystem Spec
Old 05-05-2007   #2 (permalink)
IJuan
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 SpecsSystem Spec
Old 05-05-2007   #3 (permalink)
IJuan
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 SpecsSystem Spec
Old 05-05-2007   #4 (permalink)
Alan
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 SpecsSystem Spec
Closed Thread

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


Update your Vista Drivers Update Your Vista Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008
Page generated in 0.29197 seconds with 10 queries