Last active
September 3, 2019 00:26
-
-
Save rezarahimian/9664dc6256c00cd3bb0b1dbea0b21275 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[CmdletBinding()] | |
Param() | |
$VMPath = "D:\VMs" | |
$VMName = "ClearOS" | |
$VHDPath = Join-Path -Path $VMPath -ChildPath "$VMName\Virtual Hard Disks\$VMName.VHDX" | |
$ISOPath = "I:\ISO\ClearOS-DVD-x86_64.iso" | |
# Creating new 20GB fixed VHDX. | |
New-VHD -Path $VHDPath -SizeBytes 20GB -Fixed -Verbose | |
# Creating VM by assigning required resources | |
New-VM -Name $VMName -Path $VMPath -MemoryStartupBytes 2GB -VHDPath $VHDPath -Generation 1 -Verbose | |
Set-VM -Name $VMName -AutomaticStartAction Start | |
Set-VMProcessor -VMName $VMName -Count 2 -Verbose | |
Set-VMDvdDrive -VMName $VMName -ControllerNumber 1 -Path $ISOPath -Verbose | |
Add-VMNetworkAdapter -VMName $VMName -Verbose | |
# Configuring network adapters | |
$VMAdpaters = Get-VMNetworkAdapter -VMName $VMName | |
$VMAdpaters[0] | Rename-VMNetworkAdapter -NewName "External" -Verbose | |
$VMAdpaters[0] | Connect-VMNetworkAdapter -SwitchName "External" -Verbose | |
$VMAdpaters[1] | Rename-VMNetworkAdapter -NewName "Internal" -Verbose | |
$VMAdpaters[1] | Connect-VMNetworkAdapter -SwitchName "Internal" -Verbose | |
$VMAdpaters[1] | Set-VMNetworkAdapterVlan -Trunk -AllowedVlanIdList 2-253 -NativeVlanId 254 -Verbose | |
# Turning on the new VM | |
Start-VM -Name $VMName |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment