Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 8583

Trying to use a conditional statement inside a gwmi win32_usbcontroller select object

$
0
0

I am using the below script to see if a particular usb device is connected
that equals the mfg name.  I want to return 2 lists that will show which computers have that mfg name, and which do not.  FOr example, from a list of computer names, I want to create 2 lists, one that has the usb device with name "fujitsu" and the second list for the ones without this.  This is where I reached a deadend.

Script follows....

# Script to see if the computer has a scanner attached to it.

cls
write-host "Processing started..."

foreach ($strcomputer in gc c:\batchfiles\test.txt)
{

if(Test-Path "\\$strComputer\C$\windows")
   
    {
          $computercolumn=@{
            Name = 'Computer Name'
            Expression = {"$strcomputer"}

        $list = gwmi -computer $strcomputer Win32_USBControllerDevice | %{[wmi]($_.Dependent)} | Select-Object $computercolumn, Manufacturer, name, Status |? {$_.Manufacturer -eq "Fujitsu"}
       
        $list        
        
    }

    Else
    {
       write-host "Computer offline" -fore red
    }

 }


Viewing all articles
Browse latest Browse all 8583

Latest Images

Trending Articles



Latest Images