Solved

Powershell to enable hyper-v and install virtual machine

Posted on 2014-04-07
3
666 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
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 18

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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

"Migrate" an SMTP relay receive connector to a new server using info from an old server.
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
In this Micro Tutorial viewers will learn how to use Boot Corrector from Paragon Rescue Kit Free to identify and fix the boot problems of Windows 7/8/2012R2 etc. As an example is used Windows 2012R2 which lost its active partition flag (often happen…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now