I current am using a WS2012R2 file server and it is a VM. I already have a NAS storage for backing the data up on it and now I want to add a offsite USB storage drive as well...
While it isnt much trouble plugging the drive and adding/removing it in Hyper-V Manager, it would be nice if it is all automatic.
My initial thought would be to scheduled task that detects a event (a drive being plugged in). Using a Powershell script, I would first make sure it is the serial number of the drive I want (I dont want it to do this for all drives)
After, in that script, I would use the Add-VMHardDiskDrive cmdlet with -PassThru and that should be enough.
The main issue I am currently having is finding that Event ID. Im testing this on a Windows 10 but the end scenario will be a Windows Server 2012 R2 (both Hyper-V host and VM). I dont think the event ID might have changed but then again.
The other issue I would get into is that in the VM I attach the USB HDD to, I would need to add another script that manually removes it (the user has to run this, there is no way around it). Of course, this requires a Remote Powershell session so I can run commands on the Hyper-V host to remove the HDD from the VM safely. Again, PSSession seems for the job and shouldnt be too much toruble.
I guess the biggest problem I am facing is finding a event ID to detect when a USB HDD is being plugged in. How can I solve this? I tried Event Viewer but for the love of me I cannot find the event that is triggered.