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.