0

The Powershell code is to find out which USB is communicating with the computer which is working fine.


while ($true) {
    If( gwmi win32_diskdrive  | where{$_.Interfacetype -eq "USB" } ) {
        Start-Sleep -Seconds 1
        Write-Host "$computer Connected" -ForegroundColor Green
    } 
    else {
        Start-Sleep -Seconds 1
        Write-Host "$computer Not Connected" -ForegroundColor Red
    }
}

I usually use Yubikey, but Windows recognizes it as a smartcard.

Class gwmi win32_diskdrive works fine with USB flash memory.

Class gwmi Win32_PnPEntity can show Yubikey but not trigger notifications as USB in the code.

Any suggestions?

Palle Due
  • 5,929
  • 4
  • 17
  • 32
saleem
  • 1
  • 1
  • 1

0 Answers0