As promised, I'm going to be dropping into a series of postings that are little more technical in nature. Considering that I've just come off of doing several PowerShell seminars. I thought it might be fitting to talk about a PowerShell topic. So... I decided to describe how PowerShell can be used to take snapshots of virtual machines that are running on a Virtual Server (VS). I warmly call this a poor man's VS backup solution. :>)
To complete this task, you will need to gather up the following:
1. Go grab some C# code that is on the "virtual_pc_guy" blog: Link
2. Compile this code in a dynamic link library (DLL), you will need this DLL to impersonate the COM security on the resulting VS object. The name that Ben uses for the DLL is "VSWrapperForPSH.dll".
3. Next, go grab the VSHADOW.EXE utility that comes with the VSS SDK: Link
4. Finally, go grab the latest version of robocopy.
Ok, so the first step to putting this script is to figure its logic, For example: 1. We need to take in parameters like the destination for the backup (I would also suggest an import file of servers). 2. Next, we need to load the VSWrapperForPSH.dll into the current PowerShell session. 3. Then, we need to create the Virtual Sever COM instance. 4. Next, we use the VSWrapperForPSH.dll to set the security on the VS object. 5. We need to then get a list of the VMs on the local VS server using the Net.WebClient class. 6. Finally we put in a whole bunch of logic to do the following for each VM: a. Pause it b. Take a snapshot (using vshadow.exe) c. Un-pause it d. Mount the snapshot e. robocopy the snapshot to the desired location f. Repeat Ok, that's enough for tonight. In my next post, I will put together some of the code snippets.
Advertisement: |
With more than ten years of experience in IT, Tyson Kopczynski has become a specialist in Active Directory, Information Assurance, Windows automation, PKI, and IT security practices. Tyson is also the founding author of the Windows PowerShell Unleashed series and has been a contributing author for such books as Microsoft Internet Security and Acceleration (ISA) Server 2006 Unleashed and Microsoft Windows Server 2008 Unleashed. He has also written many detailed technical papers and guides covering various technologies. As a consultant at Convergent Computing, Tyson works with and provides feedback for next generation Microsoft technologies since their inception and has also played a key role in expanding the automation and security practices at CCO. Tyson also holds such certifications as the Certified Information Systems Security Professional (CISSP), the SANS Security Essentials Certification (GSEC) and SANS Certified Incident Handler (GCIH), and the MCTS (Application Platform, Active Directory, and Network Infrastructure).
Certifications:
Publications:
Other Stuff:
Good stuff
Looking forward to seeing the code snippets. Thanks.