Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Powershell to enable hyper-v and install virtual machine

Posted on 2014-04-07
3
Medium Priority
?
694 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 1000 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 1000 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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

In previous parts of this Nano Server deployment series, we learned how to create, deploy and configure Nano Server as a Hyper-V host. In this part, we will look for a clustering option. We will create a Hyper-V cluster of 3 Nano Server host nodes w…
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
The Task Scheduler is a powerful tool that is built into Windows. It allows you to schedule tasks (actions) on a recurring basis, such as hourly, daily, weekly, monthly, at log on, at startup, on idle, etc. This video Micro Tutorial is a brief intro…

722 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