Skip to content

Instantly share code, notes, and snippets.

@mjfusa
Created July 9, 2021 16:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjfusa/b07e597fe2a6496b90eb9ffc9989340a to your computer and use it in GitHub Desktop.
Save mjfusa/b07e597fe2a6496b90eb9ffc9989340a to your computer and use it in GitHub Desktop.
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