Solved

Powershell to enable hyper-v and install virtual machine

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

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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!
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
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 process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

628 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