# ************************************************************************* # # Script Name: backupDisk2VHD.ps1 (Quick Description) # Version: 1.0 # Author: Jacob Nussbaum jdnussb@ilstu.edu (Original) # Edited: Jason Ross jlross2@ilstu.edu # Date: 072817 # # Description: Runs the disk2vhd program, copying C Drive to a share location, # and then renames the file to a date 3 months from # now to be able to delete the file. # # ************************************************************************* #$drives can be one drive identifier with colon, multiple separated by spaces, or asterisk for all drives. $drives = "C:" #Sets $computername to the computers name $computername = $env:computername #This is the path where backups are stored $uncfullpath = "\\server\share" # This is the delete date added to the end of the filename, modify the AddDays(+xxx) to change the delete date. $newdate = ((Get-Date).AddDays(+95)).ToString("yyyy-MM-dd") #This is the path where the script is currently located $scriptPath = split-path -parent $MyInvocation.MyCommand.Definition #This names the file to 'computername _ deletedate.vhdx' $filename = "$computername"+"_"+"$newdate"+".vhdx" #This is the current and the execuatable name combined. $Command = "$scriptPath" + "\" +"Disk2VHD.exe" #This is the command to accept the eula $accepteula = "/accepteula" #This combineds all the parameters into one variable $parameter = "$drives" + " " + "$uncfullpath"+"\"+"$filename" + " " + "$accepteula" #This runs the disk2vhd.exe with the arguements in parameter and waits until it finishes. Start-Process $Command -ArgumentList $parameter -Wait