![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Newbie: WMI and Powershell I am running the following command from the powershell command line: PS C:\Users\jpoling> Get-Content c:\scripts\servers.txt | Foreach-Object {Get-Wmiobject -credential $admin -computername $_ -query "SELECT CSName, Caption, CSDVersion from win32_operatingsystem"}|out-file c:\temp\test.txt PArt of the output includes the following: __GENUS : 2 __CLASS : Win32_OperatingSystem __SUPERCLASS : __DYNASTY : __RELPATH : __PROPERTY_COUNT : 3 __DERIVATION : {} __SERVER : __NAMESPACE : __PATH : Is there a way to structure the WMI query so that i do not get the above, but only the three properties I want? Any advice for a rookie is greatly appreciated. jeff |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Newbie: WMI and Powershell Perhaps this :\Users\jpoling> Get-Content c:\scripts\servers.txt | Foreach-Object {Get-Wmiobject -credential $admin -computername $_ -query "SELECT * from win32_operatingsystem"} | Select CSName,Caption,CSDVersion | out-file c:\temp\test.txt Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject J> I am running the following command from the powershell command line: J> J> PS C:\Users\jpoling> Get-Content c:\scripts\servers.txt | J> Foreach-Object {Get-Wmiobject -credential $admin -computername $_ J> -query "SELECT CSName, Caption, CSDVersion from J> win32_operatingsystem"}|out-file c:\temp\test.txt J> J> PArt of the output includes the following: J> J> __GENUS : 2 J> __CLASS : Win32_OperatingSystem J> __SUPERCLASS : J> __DYNASTY : J> __RELPATH : J> __PROPERTY_COUNT : 3 J> __DERIVATION : {} J> __SERVER : J> __NAMESPACE : J> __PATH : J> Is there a way to structure the WMI query so that i do not get the J> above, but only the three properties I want? J> J> Any advice for a rookie is greatly appreciated. J> J> jeff J> |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Newbie: WMI and Powershell > :\Users\jpoling> Get-Content c:\scripts\servers.txt | Foreach-Object Quote: > {Get-Wmiobject -credential $admin -computername $_ -query "SELECT * from > win32_operatingsystem"} | Select CSName,Caption,CSDVersion | out-file > c:\temp\test.txt Jeff |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Newbie: WMI and Powershell Im glad it helped. For more info on Select-object PS> Get-Help Select-Object -full I should note, Select-object does change the type of the object so its not always the answer. Brandon Shell --------------- Blog: http://www.bsonposh.com/ PSH Scripts Project: www.codeplex.com/psobject Quote: Quote: >> :\Users\jpoling> Get-Content c:\scripts\servers.txt | Foreach-Object >> {Get-Wmiobject -credential $admin -computername $_ -query "SELECT * >> from win32_operatingsystem"} | Select CSName,Caption,CSDVersion | >> out-file c:\temp\test.txt >> J> J> Jeff J> |
My System Specs![]() |
| | #5 (permalink) |
| | Re: Newbie: WMI and Powershell On Oct 11, 11:34 pm, "Jeff" <jeffpol...@xxxxxx> wrote: Quote: > I am running the following command from the powershell command line: > > PS C:\Users\jpoling> Get-Content c:\scripts\servers.txt | Foreach-Object > {Get-Wmiobject -credential $admin -computername $_ -query "SELECT CSName, > Caption, CSDVersion from win32_operatingsystem"}|out-file c:\temp\test.txt > > PArt of the output includes the following: > > __GENUS : 2 > __CLASS : Win32_OperatingSystem > __SUPERCLASS : > __DYNASTY : > __RELPATH : > __PROPERTY_COUNT : 3 > __DERIVATION : {} > __SERVER : > __NAMESPACE : > __PATH : > > Is there a way to structure the WMI query so that i do not get the above, > but only the three properties I want? > > Any advice for a rookie is greatly appreciated. > > jeff Try this one. I use Select-Object to grab just the properties i want. Get-Content c:\scripts\servers.txt | Foreach-Object{Get-Wmiobject - credential $admin -computername $_ -query {SELECT * from win32_operatingsystem} | select-object CSName,Caption,CSDersion} | out- file c:\temp\test.txt Regards, Kuma |
My System Specs![]() |
| | #6 (permalink) |
| | Re: Newbie: WMI and Powershell > Hey Jeff, Quote: > Try this one. I use Select-Object to grab just the properties i want. > > Get-Content c:\scripts\servers.txt | Foreach-Object{Get-Wmiobject - > credential $admin -computername $_ -query {SELECT * from > win32_operatingsystem} | select-object CSName,Caption,CSDersion} | out- > file c:\temp\test.txt I appreciate the advice! Jeff |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Powershell Newbie | PowerShell | |||
| powershell newbie help | PowerShell | |||
| Newbie to Powershell | PowerShell | |||
| Newbie to PowerShell | PowerShell | |||
| newbie - How to use FTP in powershell | PowerShell | |||