Solved

Powershell to enable hyper-v and install virtual machine

Posted on 2014-04-07
3
681 Views
Last Modified: 2014-11-12
I'm trying to script the following procedure.
1. Enable hyper-v feature
2. Create external switch
3. Create a virtual machine with provide iso file.

I thought if I go through GUI, at the end of each step, the option to export it as powershell script, but I don't see it. Do I have to dig in online to find each step how to script it or is there a way I can export to script, but am blind not finding anywhere?

platform: windows 8.1 pro
0
Comment
Question by:crcsupport
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 95

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 250 total points
ID: 39984079
Enable/Disable Hyper-v can be done with DISM from the command line:
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /All

But if you really want to do it in PowerShell:
http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/08/using-powershell-to-set-up-hyper-v.aspx

Creating Switches with PowerShell:
http://blogs.technet.com/b/heyscriptingguy/archive/2013/10/09/use-powershell-to-create-virtual-switches.aspx

And for creating the VM, I suggest reviewing this 3-part blog, starting with part 1:
http://blogs.technet.com/b/heyscriptingguy/archive/2013/06/14/create-a-new-virtual-machine-with-windows-powershell-part-1.aspx
0
 
LVL 19

Accepted Solution

by:
Raheman M. Abdul earned 250 total points
ID: 39984082
1.
Import-Module servermanager
Add-WindowsFeature Hyper-V

2.
This will help you:
http://itproctology.blogspot.co.uk/2012/03/creating-external-virtual-switch-in.html

$if = Get-NetIPAddress –IPv4Address 192* | Get-NetIPInterface
New-VMSwitch -NetAdapterName $if.ifAlias -Name VMs –AllowManagementOS $false

3.   Refer: http://www.thegeekstuff.com/2014/02/create-vm-from-powershell/
To create VM and the ISO map to the VM
0
 
LVL 1

Author Comment

by:crcsupport
ID: 39984087
Thanks for it. So, there's no really an option to export to script at the end of configuration in Add/Remove Windows Feature and Hyper-V Manager. .

I don't know why I had an impression that Microsoft Windows 8/2013 provide options to export as script on all configuration windows..
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
Optimized for private cloud infrastructures and datacenters, Nano Server is minimalistic, yet super-efficient, OS for services such as Hyper-V and Hyper-V cluster. Learn how you can easily deploy Nano Server and unlock its power!
This tutorial will walk an individual through the process of installing of Data Protection Manager on a server running Windows Server 2012 R2, including the prerequisites. Microsoft .Net 3.5 is required. To install this feature, go to Server Manager…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question