Solved

Powershell to enable hyper-v and install virtual machine

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

OfficeMate Freezes on login or does not load after login credentials are input.
A procedure for exporting installed hotfix details of remote computers using powershell
In this Micro Tutorial viewers will learn how to restore single file or folder from Bare Metal backup image of their system. Tutorial shows how to restore files and folders from system backup. Often it is not needed to restore entire system when onl…
This Micro Tutorial will show you how to maximize your wireless card to its maximum capability. This will be demonstrated using Intel(R) Centrino(R) Wireless-N 2230 wireless card on Windows 8 operating system.

863 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

21 Experts available now in Live!

Get 1:1 Help Now