Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/UsefulScripts01/PSHyperVTemplate

Create Hyper-V virtual machines from XML templates
https://github.com/UsefulScripts01/PSHyperVTemplate

hyper-v powershell virtual-machine xml

Last synced: about 2 months ago
JSON representation

Create Hyper-V virtual machines from XML templates

Lists

README

        

## PSHyperVTemplate

### Create Hyper-V virtual machines from XML templates.

### Installation

Copy the code from the area below and paste it into PowerShell Admin (or Windows Terminal).

```powershell
Install-Module -Name PSHyperVTemplate
Import-Module -Name PSHyperVTemplate
```


### Default settings for a new machine

The default settings for a new VM are stored in `"C:\Temp\VmTemplates\DefaultTemplate.xml"`. Copy this file to create additional templates.

```xml

VM
2
0

8
1
16


4
1


100
C:\Users\Public\Documents\Hyper-V\Virtual hard disks\


C:\MDT\Boot\LiteTouchPE_x64.iso


Default Switch

0
0
0

```


### Parameters

You can define your own parameter values or use the predefined ones from the VmTemplate.xml file.

`-Template` - [string] Chose XML template to use \
`-Name` - [string] Name of a new machne (default is "VM_no") \
`-Generation` - [string] Generation of a new machine (1 or 2, default is 2) \
`-ISO` - [string] Boot ISO file path \
`-Start` - [switch] Start the machine after creation \
`-RunManager` - [switch] Run Hyper-V Manager


### Examples

Example 1: Simple, all parameters from the DefaultTemplate.xml.
```powershell
New-Vmachine
```
Example 2: Generation 2. Start after creation.
```powershell
New-Vmachine -Generation 2 -Start
```
Example 3: Generation 1. Use the "Linux.xml" template file..
```powershell
New-Vmachine -Generation 1 -Template "Linux"
```
Example 4: Generation 1, boot from the ISO file defined in the parameter.
```powershell
New-Vmachine -Generation 1 -Name "MachineName" -ISO "C:\installation.iso"
```
Example 5: Remove selected machine.
```powershell
Remove-Vmachine -Name "MachineName"
```