Windows 10: Start Backup Task upon USB Device Recognition if Last Modified >7 Days

Discus and support Start Backup Task upon USB Device Recognition if Last Modified >7 Days in Windows 10 Network and Sharing to solve the problem; Goal is to start a Backup-Task while or when a specific USB Device is present. While researching I came across this old thread: Task Scheduler: How... Discussion in 'Windows 10 Network and Sharing' started by NDa-82, Apr 4, 2021.

  1. NDa-82 Win User

    Start Backup Task upon USB Device Recognition if Last Modified >7 Days


    Goal is to start a Backup-Task while or when a specific USB Device is present.

    While researching I came across this old thread:


    Task Scheduler: How to automatically synchronize my USB flash - Microsoft Community from SpiritX and tried to go from there.


    unfortunatly this does not work properly and I am stuck, could need a little help getting this done.


    #Requires -version 2.0

    Register-WmiEvent -Class win32_VolumeChangeEvent -SourceIdentifier volumeChange

    do{

    $newEvent = Wait-Event -SourceIdentifier volumeChange

    $eventType = $newEvent.SourceEventArgs.NewEvent.EventType

    $eventTypeName = switch$eventType

    {

    1 {"Configuration changed"}

    2 {"Device arrival"}

    3 {"Device removal"}

    4 {"docking"}

    }

    write-host get-date -format s " Event detected = " $eventTypeName

    if $eventType -eq 4

    {

    $driveLetter = $newEvent.SourceEventArgs.NewEvent.DriveName

    $driveLabel = [wmi]"Win32_LogicalDisk='$driveLetter'".VolumeName

    write-host get-date -format s " Drive name = " $driveLetter

    write-host get-date -format s " Drive label = " $driveLabel

    if $driveLetter -eq 'X:' -and $driveLabel -eq 'Backup-Drive'

    {

    $fullPath = "X:\Backups"

    $numdays = 7

    $numhours = 0

    $nummins = 0

    }

    function CheckFileDate$path, $days, $hours, $mins

    {

    $file = Get-ChildItem Sort-Object

    {

    [DateTime]:Start Backup Task upon USB Device Recognition if Last Modified >7 Days :parseExact$_.BaseName,'\Te\s\t\-yyyyMMdd\-HHmm',$null

    }

    Select-Object -Last 1

    {

    if$_.LastWriteTime -lt Get-Date.AddDays-$days.AddHours-$hours.AddMinutes-$mins

    }

    write-host get-date -format s

    start-sleep -seconds 300

    start-ScheduledTask -AsJob -Taskpath "\%SystemRoot%\Tasks\" -TaskName "Backup1234"

    }

    if $eventType -eq 2
    {

    $driveLetter = $newEvent.SourceEventArgs.NewEvent.DriveName

    $driveLabel = [wmi]"Win32_LogicalDisk='$driveLetter'".VolumeName

    write-host get-date -format s " Drive name = " $driveLetter

    write-host get-date -format s " Drive label = " $driveLabel

    if $driveLetter -eq 'X:' -and $driveLabel -eq 'Backup-Drive'

    {

    $fullPath = "X:\Backups"

    $numdays = 7

    $numhours = 0

    $nummins = 0

    }

    function CheckFileDate$path, $days, $hours, $mins

    {

    $file = Get-ChildItem Sort-Object

    {

    [DateTime]:Start Backup Task upon USB Device Recognition if Last Modified >7 Days :parseExact$_.BaseName,'\Te\s\t\-yyyyMMdd\-HHmm',$null

    }

    Select-Object -Last 1

    {

    if$_.LastWriteTime -lt Get-Date.AddDays-$days.AddHours-$hours.AddMinutes-$mins

    }

    write-host get-date -format s

    start-sleep -seconds 300

    start-ScheduledTask -AsJob -Taskpath "\%SystemRoot%\Tasks\" -TaskName "Backup1234"

    }

    Remove-Event -SourceIdentifier volumeChange

    } while 1-eq1 #Loop until next event

    Unregister-Event -SourceIdentifier volumeChange

    :)
     
    NDa-82, Apr 4, 2021
    #1

  2. USB Devices Inconsistent Recognition in Laptop Upgraded to Windows 10

    Hi Robert,

    To correct your issue with connecting USB devices, we suggest you to perform the steps below on running a
    System File Checker for this will fix .dll files which are associated with drivers:

    • Right-click the Start button, then select Command Prompt (Admin).
    • Enter sfc /scannow (note the space between "sfc" and "/").

    It is also recommended for you to make sure that the USB devices are removed properly from the system by clicking on safely remove USB device option.

    Let us know how it goes.

    Regards.
     
    Angela Pun, Apr 4, 2021
    #2
  3. Cannot modify Task Bar settings

    Hi,

    Thank you for posting in Microsoft Community.

    I understand your concern and will be happy to assist you.

    I suggest you to follow the steps below and check if the issue persists.

    • Right click on the Task Bar.
    • Uncheck the option " Lock the Taskbar."

    Hope this helps.
     
    Arvind Ram, Apr 4, 2021
    #3
  4. Junaid_A Win User

    Start Backup Task upon USB Device Recognition if Last Modified >7 Days

    USB recognition

    Hi Allan,

    Thank you for writing to Microsoft Community forum.

    • Does the Joy Stick work on other computers?

    If yes, you may try the troubleshooting steps listed in
    Error: “USB Device not recognized” when you try to access a USB external hard drive
    and check if it works.

    Note:

    Modifying BIOS/ complementary metal oxide semiconductor (CMOS) settings incorrectly can cause serious problems that may prevent your computer from booting properly. Microsoft cannot guarantee that any problems resulting
    from the configuring of BIOS/CMOS settings can be solved. Modifications of the settings are at your own risk.

    Tick ‘Yes’ if you find the answer helpful.

    Regards,
     
    Junaid_A, Apr 4, 2021
    #4
Thema:

Start Backup Task upon USB Device Recognition if Last Modified >7 Days

Loading...
  1. Start Backup Task upon USB Device Recognition if Last Modified >7 Days - Similar Threads - Start Backup Task

  2. Desktop not starting up for the last 2 days

    in Windows 10 Gaming
    Desktop not starting up for the last 2 days: Hey, I've googled for help and followed YouTube guides for the laat 2 days and still my PC Windows 10 will not function properly. I've had this pc since 2016. I don't game or download anything suscipious. It's just for making music, YouTube and making movies. I clean up...
  3. Desktop not starting up for the last 2 days

    in Windows 10 Software and Apps
    Desktop not starting up for the last 2 days: Hey, I've googled for help and followed YouTube guides for the laat 2 days and still my PC Windows 10 will not function properly. I've had this pc since 2016. I don't game or download anything suscipious. It's just for making music, YouTube and making movies. I clean up...
  4. Desktop not starting up for the last 2 days

    in Windows 10 BSOD Crashes and Debugging
    Desktop not starting up for the last 2 days: Hey, I've googled for help and followed YouTube guides for the laat 2 days and still my PC Windows 10 will not function properly. I've had this pc since 2016. I don't game or download anything suscipious. It's just for making music, YouTube and making movies. I clean up...
  5. USB device recognition problems

    in Windows 10 Drivers and Hardware
    USB device recognition problems: Whenever I plug in my ps4 controller to my pc via usb 2.0 port. It just glows orange instead of recognizing it as a device. I have tried every single port on my computer including usb 3.1 and cannot figure out a solution....
  6. Windows 10 not activated Upon using USB ISO to Update a Windows 7 Device

    in Windows 10 Updates and Activation
    Windows 10 not activated Upon using USB ISO to Update a Windows 7 Device: I recently purchased a used Dell Optiplex that had Windows 7. I installed a new SSD into the computer. I then used a USB Flashdrive to update the computer to Windows 10, onto the SSD. I also formatted the Hard Drive during this time. Upon completion, Windows had not...
  7. Started getting BSOD in the last three days.

    in Windows 10 BSOD Crashes and Debugging
    Started getting BSOD in the last three days.: Hello, in the last three day I started getting BSOD. I'm a Windows 10 Pro 64 user. Here's the memory dump It's usually a ndu.sys issue, so I guess a network problem? But I didn't change anyhing in the past few months......
  8. 25 (day?) uptime upon starting. Is this normal?

    in Windows 10 Ask Insider
    25 (day?) uptime upon starting. Is this normal?: [ATTACH] submitted by /u/bubbshalub [link] [comments] https://www.reddit.com/r/Windows10/comments/g1e5qh/25_day_uptime_upon_starting_is_this_normal/
  9. Modified Macrium backup

    in Windows 10 Backup and Restore
    Modified Macrium backup: Dell Inspiron 15 5565, Win 10 Home I want to create a Mactium backup, but it's going to be huge unless I can properly modify it. I tried to use a USB with 28gb free space as the destination, but it wasn't enough [img] My first question is can I just image the first 4...
  10. last usb device not recognized

    in Windows 10 Drivers and Hardware
    last usb device not recognized: How do I repair this please? https://answers.microsoft.com/en-us/windows/forum/windows_10-hardware/last-usb-device-not-recognized/8ee1f34f-0be3-486b-9262-9d60a5245578