/build/static/layout/Breadcrumb_cap_w.png

Use PowerShell to Create a VHD and Backup User Data

Video Transcript

Hi, this is Jeff Hicks. Today I want to talk about using PowerShell and a VHD file to back up a user's documents. You may what to do this as a normal course of events to periodically backup a user's file or you may want to do a quick backup before you are fixing a problem on their computer. I have built a script which you can download from the accompanying blog article to this video which will use PowerShell and discpart and dynamically create a VHD. Once we have that VHD we can then copy files to it, such as the users documents folder.

I am going to start a PowerShell session as an administrator. I am logged on normally as a regular user. Let me log on and start this PowerShell session though with the administrator account. Now, I have on the File Server in this office a PowerShell script that will create the VHD based on the total size of the files in the user's home documents folder. Let's go ahead and run this script here, \\chi-fp01\scripts\DocBackup-to-VHD.ps1. I need to specify a few parameters so let's back up -Path c:\users\afredo\documents, and we are going to put this -VHDPath \\chi-fp01\backup\afredo.vhs -we also need to specify a drive letter that we going to map this to, map this to drive Z and we will hit enter.

It looks like Al has about 40 MB of files in his documents folder. I just created the VHD, the PowerShell bit and now it is copying the files. And then it is finished. Down here I have a display, open the folder, view the files. There they are.' We also configured this VHD to be compressed. So, I have configured some extra space here. Here are all of his files and I can copy other things in or delete them off. I can now work without worrying about losing any files.

When I am finished and I want to detach this. The easy way to do this and this does requires admin privileges. Since I have already logged on as admin in PowerShell. I am going to run diskmgmt.msc. Or you can also get to this in the Computer Management console. Right-click and then Detach VHD and I will detach this and now it is disconnected.' That VHD file is still on that network share. If I need to reattach it to copy files back I have it available to me.

There is kind of a handy technique. Again grab the PowerShell scripts from the blog article to see how you can work with VHD to do some quick and dirty backups. Thank you very much for your time.


Comments

  • Anyone know where I can find a copy of this script? - kdrohan 11 years ago
This post is locked
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ