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?

  • Most OSes have a method for performing unattended installation, which you could leverage. are you asking whether you can write an unattend script in powershell? – Frank Thomas Jul 19 '17 at 05:22
  • 1
    Is this perhaps about Hyper-V? Because I don’t see how PowerShell would help me boot an ISO image. – Daniel B Jul 19 '17 at 05:26
  • powershell is not a virtual machine, hence cannot boot anything – phuclv Jul 19 '17 at 05:30
  • Oh, hmmm. I was using this as my guide. Maybe I was understanding it wrong? https://superuser.com/questions/499264/how-can-i-mount-an-iso-via-powershell-programmatically – Hayden B. Siegel Jul 19 '17 at 19:06
  • ok. that thread does in fact mount an ISO, but it doesn't boot off it. Those ISOs have a windows autoplay executable, so your booted OS is just running a windows program off the disk image, not booting off it. if you rebooted in order to boot into another OS, the mounted iso would not be available to the system firmware as bootable media, so you could only do what you suggest with a virtual machine. Otherwise you have to burn the iso to disk or usb, and physically load it, before the bios/firmware could find it to boot from. – Frank Thomas Jul 21 '17 at 02:07

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