powershell : how to detect an uninstalled usb device? Announcing the arrival of Valued...

Sally's older brother

How to ternary Plot3D a function

A term for a woman complaining about things/begging in a cute/childish way

Nose gear failure in single prop aircraft: belly landing or nose-gear up landing?

Found this skink in my tomato plant bucket. Is he trapped? Or could he leave if he wanted?

How can I prevent/balance waiting and turtling as a response to cooldown mechanics

Did Mueller's report provide an evidentiary basis for the claim of Russian govt election interference via social media?

What is the origin of 落第?

Why not send Voyager 3 and 4 following up the paths taken by Voyager 1 and 2 to re-transmit signals of later as they fly away from Earth?

What are the main differences between the original Stargate SG-1 and the Final Cut edition?

Google .dev domain strangely redirects to https

The Nth Gryphon Number

Mounting TV on a weird wall that has some material between the drywall and stud

What does it mean that physics no longer uses mechanical models to describe phenomena?

Putting class ranking in CV, but against dept guidelines

Why is a lens darker than other ones when applying the same settings?

How much damage would a cupful of neutron star matter do to the Earth?

NERDTreeMenu Remapping

A `coordinate` command ignored

Can an iPhone 7 be made to function as a NFC Tag?

Is openssl rand command cryptographically secure?

Should a wizard buy fine inks every time he want to copy spells into his spellbook?

Why does electrolysis of aqueous concentrated sodium bromide produce bromine at the anode?

What does Turing mean by this statement?



powershell : how to detect an uninstalled usb device?



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Where can I find logs on recent USB insertion in the Event Viewer?“USB Device Not Recognized” from USB Storage devicesInstalling USB device on VMware Workstation MachineNotebook doesn't detect boot devicesWhy does Windows XP ask for installation of new USB device every time?USB device Disabled MavericksWindows 10 USB only working if device plugged in during bootUSB device working after driver uninstalledUSB Webcam works on 2 out of 3 machines?Task scheduler : How to detect that a usb device is unplugged?USB device only connects via hub





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I would like my Powershell script to detect when I plug in a usb device. I have set the GPOs to block the automatic installation of usb devices.



For now I am using this command to detect when a usb device is plugged in :



$query = SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveYpe=23


Register-WmiEvent -Query $query -SourceIdentifier RemovableDiskDetection -Action {...}


But probably because the device isn't installed, the event is not detected and nothing happens.
What sort of query should I use to detect when a usb device is plugged in even if the driver of the usb device are not yet installed on the machine ?










share|improve this question

























  • There are USB devices other than mass storage devices though? What exactly did you block and what exactly are you trying to see? Unless the GPO malfunctions, a drive device won’t appear.

    – Daniel B
    Jul 23 '18 at 14:19











  • No there is no other USB device besides my USB key. I enabled the GPO "Prevent installation of removable devices " and "Prevent installation of devices not described by other policy settings." I want to register a Powershell event that will detect when I plug a usb device is plugged in and will display a message, for example "USB detected". This works well when the GPO are not enabled but I do not want usb devices to be autmatically installed.

    – M.Brbr
    Jul 24 '18 at 7:05


















1















I would like my Powershell script to detect when I plug in a usb device. I have set the GPOs to block the automatic installation of usb devices.



For now I am using this command to detect when a usb device is plugged in :



$query = SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveYpe=23


Register-WmiEvent -Query $query -SourceIdentifier RemovableDiskDetection -Action {...}


But probably because the device isn't installed, the event is not detected and nothing happens.
What sort of query should I use to detect when a usb device is plugged in even if the driver of the usb device are not yet installed on the machine ?










share|improve this question

























  • There are USB devices other than mass storage devices though? What exactly did you block and what exactly are you trying to see? Unless the GPO malfunctions, a drive device won’t appear.

    – Daniel B
    Jul 23 '18 at 14:19











  • No there is no other USB device besides my USB key. I enabled the GPO "Prevent installation of removable devices " and "Prevent installation of devices not described by other policy settings." I want to register a Powershell event that will detect when I plug a usb device is plugged in and will display a message, for example "USB detected". This works well when the GPO are not enabled but I do not want usb devices to be autmatically installed.

    – M.Brbr
    Jul 24 '18 at 7:05














1












1








1








I would like my Powershell script to detect when I plug in a usb device. I have set the GPOs to block the automatic installation of usb devices.



For now I am using this command to detect when a usb device is plugged in :



$query = SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveYpe=23


Register-WmiEvent -Query $query -SourceIdentifier RemovableDiskDetection -Action {...}


But probably because the device isn't installed, the event is not detected and nothing happens.
What sort of query should I use to detect when a usb device is plugged in even if the driver of the usb device are not yet installed on the machine ?










share|improve this question
















I would like my Powershell script to detect when I plug in a usb device. I have set the GPOs to block the automatic installation of usb devices.



For now I am using this command to detect when a usb device is plugged in :



$query = SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE TargetInstance ISA 'Win32_LogicalDisk' AND TargetInstance.DriveYpe=23


Register-WmiEvent -Query $query -SourceIdentifier RemovableDiskDetection -Action {...}


But probably because the device isn't installed, the event is not detected and nothing happens.
What sort of query should I use to detect when a usb device is plugged in even if the driver of the usb device are not yet installed on the machine ?







usb powershell events






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 23 '18 at 14:07







M.Brbr

















asked Jul 23 '18 at 12:58









M.BrbrM.Brbr

579




579













  • There are USB devices other than mass storage devices though? What exactly did you block and what exactly are you trying to see? Unless the GPO malfunctions, a drive device won’t appear.

    – Daniel B
    Jul 23 '18 at 14:19











  • No there is no other USB device besides my USB key. I enabled the GPO "Prevent installation of removable devices " and "Prevent installation of devices not described by other policy settings." I want to register a Powershell event that will detect when I plug a usb device is plugged in and will display a message, for example "USB detected". This works well when the GPO are not enabled but I do not want usb devices to be autmatically installed.

    – M.Brbr
    Jul 24 '18 at 7:05



















  • There are USB devices other than mass storage devices though? What exactly did you block and what exactly are you trying to see? Unless the GPO malfunctions, a drive device won’t appear.

    – Daniel B
    Jul 23 '18 at 14:19











  • No there is no other USB device besides my USB key. I enabled the GPO "Prevent installation of removable devices " and "Prevent installation of devices not described by other policy settings." I want to register a Powershell event that will detect when I plug a usb device is plugged in and will display a message, for example "USB detected". This works well when the GPO are not enabled but I do not want usb devices to be autmatically installed.

    – M.Brbr
    Jul 24 '18 at 7:05

















There are USB devices other than mass storage devices though? What exactly did you block and what exactly are you trying to see? Unless the GPO malfunctions, a drive device won’t appear.

– Daniel B
Jul 23 '18 at 14:19





There are USB devices other than mass storage devices though? What exactly did you block and what exactly are you trying to see? Unless the GPO malfunctions, a drive device won’t appear.

– Daniel B
Jul 23 '18 at 14:19













No there is no other USB device besides my USB key. I enabled the GPO "Prevent installation of removable devices " and "Prevent installation of devices not described by other policy settings." I want to register a Powershell event that will detect when I plug a usb device is plugged in and will display a message, for example "USB detected". This works well when the GPO are not enabled but I do not want usb devices to be autmatically installed.

– M.Brbr
Jul 24 '18 at 7:05





No there is no other USB device besides my USB key. I enabled the GPO "Prevent installation of removable devices " and "Prevent installation of devices not described by other policy settings." I want to register a Powershell event that will detect when I plug a usb device is plugged in and will display a message, for example "USB detected". This works well when the GPO are not enabled but I do not want usb devices to be autmatically installed.

– M.Brbr
Jul 24 '18 at 7:05










1 Answer
1






active

oldest

votes


















0














It appears that this question is a near enough duplicate to the question here: Where can I find logs on recent USB insertion in the Event Viewer?






share|improve this answer
























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "3"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1342565%2fpowershell-how-to-detect-an-uninstalled-usb-device%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    It appears that this question is a near enough duplicate to the question here: Where can I find logs on recent USB insertion in the Event Viewer?






    share|improve this answer




























      0














      It appears that this question is a near enough duplicate to the question here: Where can I find logs on recent USB insertion in the Event Viewer?






      share|improve this answer


























        0












        0








        0







        It appears that this question is a near enough duplicate to the question here: Where can I find logs on recent USB insertion in the Event Viewer?






        share|improve this answer













        It appears that this question is a near enough duplicate to the question here: Where can I find logs on recent USB insertion in the Event Viewer?







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 6 hours ago









        DBADonDBADon

        766




        766






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Super User!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1342565%2fpowershell-how-to-detect-an-uninstalled-usb-device%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            VNC viewer RFB protocol error: bad desktop size 0x0I Cannot Type the Key 'd' (lowercase) in VNC Viewer...

            Tribunal Administrativo e Fiscal de Mirandela Referências Menu de...

            looking for continuous Screen Capture for retroactivly reproducing errors, timeback machineRolling desktop...