0

I've recently started learning Powershell and I found out that I can load and boot to a new ISO using Powershell, but is there anyway to use it to actually install the OS using that ISO image?

Hayden
  • 111

1 Answers1

0

I am going to assume that you are working with Hyper-V and also with Windows images and that your goal is to make on click and install a new VM script with windows powerhsell:

The commands to start and turn off any VM in hyper-v are this:

Start-VM -Name $VMName

Stop-VM -Name $VMName

Second if using Hyper-v set the boot device to start one virtual machine, you just need to do the following:

$VMName=VM1
$ISOPath=C:\Windows10-dvd.iso

Add DVD Drive to Virtual Machine and Mount the ISO on the VM

Add-VMScsiController -VMName $VMName Add-VMDvdDrive -VMName $VMName -ControllerNumber 1 -ControllerLocation 0 -Path $ISOPath

Get the drive letter on the VM

$DVDDrive = Get-VMDvdDrive -VMName $VMName

Configure Virtual Machine to Boot from DVD ISO you have mounted

Set-VMFirmware -VMName $VMName -FirstBootDevice $DVDDrive

Now the only issue here is the ISO you are using to install windows, you can even include updates and many other fun things, but i think that is for another thread alone. There is no need to input manually the actions to install windows, and also since the machine is blank it has no IP address so you cannot do one remote powershell session to the virtual machine using the network.

If you want try researching on the Windows Deployment Tools or Windows System Image manager that should lead you in the right path to create one click and go VM deployment script. And also ISO images that need no action from the user to install windows.

If you have any other question just let me know i like Microsoft tools they are always breaking, so i have found my living in fixing them :)

Att: Juan