I discovered this problem while setting up a Windows 2012 Backup to a Virtual Hard Drive (VHD). What I found is that Microsoft does a lousy job of connecting VHD files as disks. The problem is that the disks are not reconnected after your server is restarted. So if you need the VHD to be available to an unattended machine, like in the case of using the VHD as a backup storage location, then you have a real problem. Unless, that is you follow these simple steps to schedule a tasks that will reconnect the VHD every time the server starts.
First we need to create 2 files, one is a simple batch file that launches diskpart and then executes the command in the second text file. Here is the code inside of those files:
DiskPart /s "c:\scripts\AttachVHD_ServerName.txt"
select vdisk file="\\Server\Folder\YourBackupDrive.vhdx" attach vdisk
Save these in your C:\Scripts folder. (If your reading this your smart enough to know what to change in the code to use a different location)
Now all we have to do is create a scheduled task that launches C:\Scripts\AttachVHD.bat whenever the server starts. Make sure you set the task to run whether the user is logged on or not and check the box next to run with highest privileges.
Pingback: Windows 2012 Backup to a Virtual Hard Drive (VHD) | Xpert Notes