Scripting Virtual Server with PowerShell - CAP-ISO.ps1

Hello Everyone

As promised, attached is the first fo the demo scripts that I used at the “Scripting Virtual Server with PowerShell” session I ran. I`m not going to go through the whole script but here is an over view and bit more detail on a few key sections.

Script Synopsis

CAP-ISO.ps1 stands for CreateAndPresent-ISO.ps1. This script can be used to create an ISO file comprising of a given set of files. This iso is then presented to a guest VM. I find this particularly useful to run on my laptop with Virtual Server installed. Essentially this is a quick way of getting files from a host to a guest without having to worry about the network setup.

 

Interesting Bits

I should probably give this section a more descriptive title, but you get the idea. Here’s some of the more interesting sections of the script.

 

Firstly, this script just wraps around an existing command line tool to create the ISO. This tool is called OSCDIMG.EXE and ships with the Windows Automated Installation Kit (WAIK). You will need to download the tool, and modify the script to point to its install location. The WAIK can be downloaded here: https://www.microsoft.com/downloads/details.aspx?familyid=C7D4BC6D-15F3-4284-9123-679830D629F2&displaylang=en

Let’s look at some code. I don’t want to duplicate what Virtual PC Guy, Ben Armstrong has already written so for a basic guide to scripting Virtual Server with PowerShell go here: https://blogs.msdn.com/virtual_pc_guy/archive/2006/06/13/630165.aspx

So, as Ben Armstrong discussed, you must first have the dll somewhere on the system, and then must reference it from the script. You also need to be running as admin (and elevated if in Vista). Here is how to reference the dll.

$result = [System.Reflection.Assembly]::LoadFrom(“$profdir\VSWrapperForPSH.dll”)

 

$profdir is a variable I have created in my profile that points the variable to my profile directory.

I then create a Virtual Server Com Instance like this:

$vs = new-object -com VirtualServer.Application -Strict

 

The next essential part is to set the security on the object. I do this using a function called setsecurity which can be called anytime. Here’s the function and an example call to it:

function setsecurity($Object)

{

     $result = [Microsoft.VirtualServer.Interop.PowerShell]::SetSecurity($Object)

    

}

$result = SetSecurity $VS

 

I then have to call this function every time I create a new Virtual Server based object. Whether it’s a VM object, DVD Drive, Hard Disk or any other object I have to set the security once I have created the object.

Have a look through the script and if you have any questions, just post them in the comment section.

For more information on scripting Virtual Server with PowerShell check out Ben Armstrong’s most excellent book, Professional Microsoft Virtual Server 2005, Wrox Publishing. Check out Ben’s blog for more information on the book:

https://mumblingtomyself.spaces.live.com/blog/cns!64FFB030F5637A64!128.entry

 

Enjoy!

 

BenP

cap-iso.ps1

Comments

  • Anonymous
    January 01, 2003
    Very usefull script by Ben Pearce on how to quickly make some files/programs available in virtual server

  • Anonymous
    January 01, 2003
    Ben Pearce a mis en ligne un script issu de sa présentation Scripting Virtual Server with PowerShell

  • Anonymous
    January 01, 2003
    I completely agree with all that here is told "So you can find the information on it on my search resource http://fileshunt.com"

  • Anonymous
    March 10, 2008
    if somebody needs asoft for this operations go to http://loadingvault.com it is a very good searcher of rapidshare files

  • Anonymous
    September 29, 2008
    I agree, http://free-fursuit.kissagirls.pl

  • Anonymous
    October 07, 2008
    Download more stuff to your mobile phone  Very usefull rapidshare search engine. In here http://4rapidsearch.com/archive you can see what people search in last hours/days.

  • Anonymous
    October 17, 2008
    very useful rapidshare searh engine too http://techebookshare.blogspot.com

  • Anonymous
    October 31, 2008
    I would like you to recomend http://filespump.com to look for files you are interested in. Now it's the best file hosting search engine in the web. More than 4 000 000 files indexed. Try it and i think you will be satisfied with search results. Use search string.

  • Anonymous
    October 31, 2008
    I would like you to recomend http://filespump.com to look for files you are interested in. Now it's the best file hosting search engine in the web. More than 4 000 000 files indexed. Try it and i think you will be satisfied with search results. Use search string.

  • Anonymous
    November 13, 2008
    Hi I want to recommend you very useful rapidshare search http://4rapidsearch.com You can find there a lot of new movies, games and music. Enjoy it!

  • Anonymous
    November 13, 2008
    Hi I want to recommend you very useful download files search http://suche-project.eu You can find there a lot of new movies, games and music. Enjoy it!

  • Anonymous
    December 23, 2008
    Very interesting and clever i found some extra stuff about it http://ddlfrog.com

  • Anonymous
    July 26, 2009
    You are right,good topic.you could find useful info by http://rapidmore.com and http://rapidsharedata.com

  • Anonymous
    March 22, 2010
    Great post! http://www.webwarez.net/ is my favourtie website.

  • Anonymous
    November 14, 2014
    Scripting Virtual Server with PowerShell - CAP-ISO.ps1 - Benp's Guide to Stuff - Site Home - TechNet Blogs