Skip to content

Instantly share code, notes, and snippets.

@mjfusa
Created July 9, 2021 16:48
Embed
What would you like to do?
Create VM with iso OS
Param(
[Parameter(Mandatory=$true)]
$VMName,
[Parameter(Mandatory=$true)]
$Memory,
[Parameter(Mandatory=$true)]
$NewVHD,
[Parameter(Mandatory=$true)]
$VHDSize,
$Switch='Default Switch',
$Cpu=2,
[Parameter(Mandatory=$true)]
$IsoPath
)
New-VM -Name $VMName –NewVHDPath $NewVHD -MemoryStartupBytes $Memory -NewVHDSizeBytes $VHDSize
ADD-VMNetworkAdapter –VMName $VMName –Switchname $Switch
SET-VMProcessor –VMName $VMName –Count 2
Set-VMDvdDrive -VMName $VMName -ControllerNumber 1 -Path $IsoPath
#New-VM -Name "vs vm" –NewVHDPath 'D:\Hyper-V\Virtual Hard Disks\vsvm.vhdx' -MemoryStartupBytes 1GB -NewVHDSizeBytes 40GB
#ADD-VMNetworkAdapter –VMName 'vs vm' –Switchname "Default Switch"
#SET-VMProcessor –VMName “vs vm” –Count 2
#Set-VMDvdDrive -VMName 'vs vm' -ControllerNumber 1 -Path "D:\iso\Windows.iso"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment