![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| Guest | Using the $_ pipeline with WMI Newbie here... I am trying to develop a list of software that needs to be uninstalled on a computer. I have the output list : IdentifyingNumber name vendor ----------------- ---- ------ {01A4AEDE-F219-49A2-B855-16A016EAF9A4} Intel(R) PROSet II Intel and am trying to iterate through the list and get-wmiobject for each IdentifyingNumber , then Unintsall. Here is what I have: get-content "c:\productsintel.txt" |Get-WmiObject -Class win32_product -Filter "IdentifyingNumber='$_.IdentifyingNumber'" 1) How do I reference the IdentifyingNumber correctly when reading the file? 2) is the "filter" syntax correct? Thanks Larry |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Using the $_ pipeline with WMI In this case it's better to use a CSV file to provide the software you want uninstalled as you can import that back as an object PoSH> $sw = (gwmi win32_product -prop IdentifyingNumber,name,vendor) PoSH> $sw | select [a-z]* |? {$_.Vendor -eq 'Macromedia'} IdentifyingNumber Name Vendor ----------------- ---- ------ {91057632-CA70-413C-B628-2D3CDBBB906B} Macromedia Flash Player 8 Plugin Macromedia PoSH> $sw | select [a-z]* |? {$_.Vendor -eq 'Macromedia'} | Export-Csv Macromedia.csv PoSH> Import-Csv Macromedia.csv |% {gwmi win32_product -filter "Vendor='$($_.vendor)'"} IdentifyingNumber : {91057632-CA70-413C-B628-2D3CDBBB906B} Name : Macromedia Flash Player 8 Plugin Vendor : Macromedia Version : 8.0.22.0 Caption : Macromedia Flash Player 8 Plugin Greetings /\/\o\/\/ http://thePowerShellGuy.Com "Larry R" <wantitoverwith@gmail.com> wrote in message news:1177610197.702375.236720@t38g2000prd.googlegroups.com... > Newbie here... > I am trying to develop a list of software that needs to be uninstalled > on a computer. > > I have the output list : > IdentifyingNumber name vendor > ----------------- ---- ------ > {01A4AEDE-F219-49A2-B855-16A016EAF9A4} Intel(R) PROSet II Intel > > > and am trying to iterate through the list and get-wmiobject for each > IdentifyingNumber , then Unintsall. > > Here is what I have: > get-content "c:\productsintel.txt" |Get-WmiObject -Class win32_product > -Filter "IdentifyingNumber='$_.IdentifyingNumber'" > > > 1) How do I reference the IdentifyingNumber correctly when reading the > file? > 2) is the "filter" syntax correct? > > Thanks > Larry > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Using the $_ pipeline with WMI Ok, so now I have $fileName = "C:\testUninstall.csv" Import-csv $fileName |% {gwmi win32_product -filter "IdentifyingNumber='$($_.IdentifyingNumber)'"} I was trying to do this: Import-csv $fileName |% { {gwmi win32_product -filter "IdentifyingNumber='$($_.IdentifyingNumber)'"} | foreach( write-host "Uninstalling " $_.name ) but I never get the name. What is the |% syntax for? |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| credential in the pipeline | PowerShell | |||
| The pipeline is empty | PowerShell | |||
| object pipeline? | PowerShell | |||
| Brackets in the pipeline | PowerShell | |||
| A pipeline exercise | PowerShell | |||