Hello all,<\/p>\n
I have script which works great, I want to include below condition and it not working<\/p>\n
if (Get-PnpDevice -InstanceID 'USB\\VID_046D&PID_C52B&MI_02\\7&366E4BAA&0&0002') { 'True' } Else { 'False' }\n<\/code><\/pre>\n
Advertisement
am I doing anything wrong?<\/p>","upvoteCount":3,"answerCount":7,"datePublished":"2018-05-23T14:09:52.000Z","author":{"@type":"Person","name":"tkr99","url":"https://community.spiceworks.com/u/tkr99"},"acceptedAnswer":{"@type":"Answer","text":"
You’ll need to use WMI instead if you’re not on Win10:<\/p>\n
$USBDevice = Get-WmiObject -class Win32_PnPEntity -Namespace \"root\\CIMV2\" | where {$_.PNPDeviceID -eq 'USB\\VID_046D&PID_C52B&MI_02\\7&366E4BAA&0&0002'}\nif ($USBDevice) { 'True' } Else { 'False' }\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2018-05-23T19:41:05.000Z","url":"https://community.spiceworks.com/t/get-pnpdevice-not-working-in-powershell/653212/6","author":{"@type":"Person","name":"tahin","url":"https://community.spiceworks.com/u/tahin"}},"suggestedAnswer":[{"@type":"Answer","text":"Hello all,<\/p>\n
I have script which works great, I want to include below condition and it not working<\/p>\n
if (Get-PnpDevice -InstanceID 'USB\\VID_046D&PID_C52B&MI_02\\7&366E4BAA&0&0002') { 'True' } Else { 'False' }\n<\/code><\/pre>\nam I doing anything wrong?<\/p>","upvoteCount":3,"datePublished":"2018-05-23T14:09:52.000Z","url":"https://community.spiceworks.com/t/get-pnpdevice-not-working-in-powershell/653212/1","author":{"@type":"Person","name":"tkr99","url":"https://community.spiceworks.com/u/tkr99"}},{"@type":"Answer","text":"
Not sure this command do not work for me may be you are looking for<\/p>\n
$this=Get-PnpDevice -InstanceID 'USB\\VID_046D&PID_C52B&MI_02\\7&366E4BAA&0&0002'\nIf($this){\n'True'\n}\nElse{\n'False'\n}\n\n<\/code><\/pre>\nTry{\nGet-PnpDevice -InstanceID 'USB\\VID_046D&PID_C52B&MI_02\\7&366E4BAA&0&0002' -erroraction stop\n}\n\nCatch{\nWrite-Warning \"$error[0]\"\n}\n<\/code><\/pre>\nsame as<\/p>\n
if(Test-Path C:\\Users){\n'True'\n}\nelse{\n'False'\n}\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2018-05-23T15:01:36.000Z","url":"https://community.spiceworks.com/t/get-pnpdevice-not-working-in-powershell/653212/2","author":{"@type":"Person","name":"jitensh","url":"https://community.spiceworks.com/u/jitensh"}},{"@type":"Answer","text":"If all you’re trying to do is return True or False in your console window, not sure why that won’t work. What result are you getting? What are you expecting to get?<\/p>","upvoteCount":0,"datePublished":"2018-05-23T17:55:25.000Z","url":"https://community.spiceworks.com/t/get-pnpdevice-not-working-in-powershell/653212/3","author":{"@type":"Person","name":"tahin","url":"https://community.spiceworks.com/u/tahin"}},{"@type":"Answer","text":"
thanks,<\/p>\n
I am getting error<\/p>\n
\"The term ‘Get-PnpDevice’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
\nAt line:1 char:14<\/p>\n
\n- Get-PnpDevice <<<<<\/li>\n
- CategoryInfo : ObjectNotFound: (Get-PnpDevice:String) <\/span>, CommandNotFoundException<\/li>\n
- FullyQualifiedErrorId : CommandNotFoundException\"<\/li>\n<\/ul>","upvoteCount":0,"datePublished":"2018-05-23T18:21:13.000Z","url":"https://community.spiceworks.com/t/get-pnpdevice-not-working-in-powershell/653212/4","author":{"@type":"Person","name":"tkr99","url":"https://community.spiceworks.com/u/tkr99"}},{"@type":"Answer","text":"
Ohhhh.<\/p>\n
Appears this cmdlet is Windows 10+<\/p>","upvoteCount":0,"datePublished":"2018-05-23T19:29:46.000Z","url":"https://community.spiceworks.com/t/get-pnpdevice-not-working-in-powershell/653212/5","author":{"@type":"Person","name":"tahin","url":"https://community.spiceworks.com/u/tahin"}},{"@type":"Answer","text":"