Enabling volume shadow copy using powershell v4/5

1
volume shadow copy server 2016

A quick Server 2016/19 script tutorial on enabling Volume Shadow copy for using Powershell v4/5

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#--------------------------------------------------------------------------------------
#Enable Volume Shadow copy
#--------------------------------------------------------------------------------------
clear
$Continue = Read-Host "Enable Volume Shadowcopy (Y/N)?"
while("Y","N" -notcontains $Continue){$Continue = Read-Host "Enable Volume Shadowcopy (Y/N)?"}
if ($Continue -eq "Y") {

	#Enable Shadows with max space of 16GB (/maxsize=16256MB)
	vssadmin add shadowstorage /for=C: /on=C:/maxsize=16256MB
	vssadmin add shadowstorage /for=D: /on=D:/maxsize=16256MB
	#Create Shadows
	vssadmin create shadow /for=C:
	vssadmin create shadow /for=D:
	#Set Shadow Copy Scheduled Task for C: AM
	$Action=new-scheduledtaskaction -execute "c:\windows\system32\vssadmin.exe" -Argument "create shadow /for=C:"
	$Trigger=new-scheduledtasktrigger -daily -at 6:00AM
	Register-ScheduledTask -TaskName ShadowCopyC_AM -Trigger $Trigger -Action $Action -Description "ShadowCopyC_AM"
	#Set Shadow Copy Scheduled Task for C: PM
	$Action=new-scheduledtaskaction -execute "c:\windows\system32\vssadmin.exe" -Argument "create shadow /for=C:"
	$Trigger=new-scheduledtasktrigger -daily -at 6:00PM
	Register-ScheduledTask -TaskName ShadowCopyC_PM -Trigger $Trigger -Action $Action -Description "ShadowCopyC_PM"
	#Set Shadow Copy Scheduled Task for D: AM
	$Action=new-scheduledtaskaction -execute "c:\windows\system32\vssadmin.exe" -Argument "create shadow /for=D:"
	$Trigger=new-scheduledtasktrigger -daily -at 7:00AM
	Register-ScheduledTask -TaskName ShadowCopyD_AM -Trigger $Trigger -Action $Action -Description "ShadowCopyD_AM"
	#Set Shadow Copy Scheduled Task for D: PM
	$Action=new-scheduledtaskaction -execute "c:\windows\system32\vssadmin.exe" -Argument "create shadow /for=D:"
	$Trigger=new-scheduledtasktrigger -daily -at 7:00PM
	Register-ScheduledTask -TaskName ShadowCopyD_PM -Trigger $Trigger -Action $Action -Description "ShadowCopyD_PM"
}

Found priceless insights in this blog? Support the author’s creativity – buy them a coffee!

1 thought on “Enabling volume shadow copy using powershell v4/5

Leave a Reply

Your email address will not be published. Required fields are marked *