Method for setting up Volume Shadow Copies on Server Core
Solution 1:
You'd think this should be easy, wouldn't you? Well, you'd be wrong. It's not.
Shadow Copies of Shared Folders is available in all editions of Windows Server 2008 R2. However, the user interface is not available for the Server Core installation option. To create shadow copies for computers with a Server Core installation, you need to manage this feature remotely from another computer.
If easy's out of the question... see this thread, where they try go at it the hard way. I love to automate things, but in this case, I think it's much more effort than just using the GUI initially.
Solution 2:
Instead of remotely configuring the setting, you could just create a scheduled task through Group Policy. As you mentioned, the task created during the normal method uses a volume ID; its action looks something like this:
vssadmin.exe Create Shadow /AutoRetry=15 /For=\\?\Volume{f9d9bfa1-f506-f24f-f54f-fe6ef47fd6f4}\
So of course the challenge for you would be making a GPO that would work for all computers.
I propose having your schedule be a small powershell snippet that finds the volume ID and calls the same command.
I'm going to assume you want to do this for the system drive. In that case, code like this should work on PowerShell 2.0+:
$volID = Get-WmiObject Win32_Volume | Where-Object { $_.DriveLetter -ieq $env:SYSTEMDRIVE } | Select-Object -ExpandProperty DeviceID
Start-Process 'vssadmin.exe' -ArgumentList "Create Shadow /AutoRetry=15 /For=$volID" -Wait
This is shown as 2 lines here so you can more easily see what's going on, but obviously if you intend to call your task without an external script file (which would complicate things) you would have to have it all on one line. You can separate the lines with a semi-colon, you could just embed the entire volume ID retrieval line in the string with $()
, etc.
You could also use powershell's -EncodedCommand
parameter to deal with quoting. This lets you have a nice readable multi-line script that you can sit on a share somewhere. You base64 encode that script and then pass the entire thing to powershell with -EncodedCommand
.
I can expand on those options if needed, assuming this code would meet your needs.