Powershell & HyperV - Create a VM in a specific folder

Well, James O'Neill has updated his library on codeplex again, but there is still a function missing that I needed. In our environment we create multiple machines and I wanted a way to create them in a specific directory, now I know I could set the default location and then create it, but I prefer to just specify a path and go from there.

I started from Ben Armstrong's code at Virtual PC Guy's Weblog and then modified the code after the VM name is set to also specify the location of the folder it will be created in.

[code:xml]

# Setthe VM name
$newVSGlobalSettingData.psbase.Properties.Item("ElementName").value = $VMName

# New code - Set Folder location
$VMFolder = "E:\DevVMs\"
$newVSGlobalSettingData.psbase.Properties.Item("ExternalDataRoot").value = $VMFolder + $VMName

[/code]

It took a little while to find the correct property to set, and I don't think that ExternalDataRoot is particularly obvious but the documentation at MSDN was helpful. In the example above, it puts the VM files in E:\DevVMs\VMName.

For our scripts I then used the HyperV Library to configure the VM with CPUs, RAM, disks and network connections.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

May 21. 2010 06:49

Need for body detox

However, the problem with free advertising is that most of it does not work.

Need for body detox

August 11. 2010 15:53

Cruises From Charleston

I found your blog on del.icio.us recently and really liked it.. i bookmarked it and will be back to check it out some more later ..

Cruises From Charleston

August 16. 2010 15:47

Premium Wordpress Themes

Do you mind if I quote you on my blog if I link back to your website?

Premium Wordpress Themes

August 18. 2010 20:55

Alan Miller

Did you know that there is a secret way of cleansing? Look at this report: http://www.healthydetoxcleanser.com/

Alan Miller

August 26. 2010 23:15

Shirl Monestime

Thanks a good deal! I truly enjoyed reading this.Looking through these posts and the information you've provided I can appreciate that I still have a lot of things to learn. I will keep reading and keep re-visiting.

Shirl Monestime

August 27. 2010 22:36

Jose

Love the post, I'll certaintly be back for more. Love - <a href="http://www.photographersinpa.com">Photographers in Pa</a>

Jose

August 28. 2010 00:11

Arron Lineberry

Extremely useful and informative article. I wish i can do all of that in a short period of time. But for sure doing those will produce results. I will try to spread your words through my blog and link it back to you. Thanks a lot for those tips

Arron Lineberry

August 28. 2010 12:30

nude chat

Your post really made me think, have you any further reading you would recommend?

nude chat

August 30. 2010 22:07

increase semen volume

your site layout is very good

increase semen volume

August 31. 2010 08:34

student driver signs

Awseome article, I am a big believer in posting comments on weblogs to help the blog writers know that they’ve added some thing of great benefit to the world wide web!

student driver signs

August 31. 2010 10:05

Nude Cam

You may have not intended to do so, but I think you have managed to express the state of mind that a lot of people are in. The sense of wanting to help, but not knowing how or where, is something a lot of us are going through.

Nude Cam

September 1. 2010 07:30

Ranae Sales

great post! i'm bookmarking this!

Ranae Sales

September 1. 2010 07:49

Janel Duttweiler

great post! i'm bookmarking this!

Janel Duttweiler

September 1. 2010 18:35

Moira

This is my first visit here, but I can already tell you that I love it! Keep up the awesome work!

Moira

September 1. 2010 20:49

Nude Cam

I think you have spent a lot of time to provide this quality article to us. I do not know how to thank you.

Nude Cam

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



 

Dilbert of the day