How can I mount and dismount ISO images from PowerShell in Windows 8 without 3rd party programs?
This question's original revision got me wondering if it's possible to mount an ISO via PowerShell in Windows 8.
|
How can I mount and dismount ISO images from PowerShell in Windows 8 without 3rd party programs? This question's original revision got me wondering if it's possible to mount an ISO via PowerShell in Windows 8. |
||||
|
|
Mount an ISO from command promptIf you're sitting at a command prompt and need to mount an ISO, run the following command:
This will invoke a PowerShell cmdlet. You will be prompted for the path of the ISOs you wish to mount. When you are done, leave the last one blank and push enter.
Tada! It's mounted:
Dismount an ISOTo dismount an ISO from PowerShell run
This command will grab the drive you specifiy, find the disk image, and dismount it.
Mounting multiple ISOs and displaying drive lettersYou can also use the -PassThru flag to store data passed to the command. Lets mount a few ISOs, display their drive letters, execute a file on one of the drives, and then dismount all the ISOs. Mount the ISOs
Display volume info for each ISO mounted using a foreach loop
List J drive
Open a file
To dismount the ISOs, use the following command:
Testing the ISOTo build a simple script that checks if the ISO is attached and is in fact an ISO (vs. a VHD) I like to use -PassThru to store the object temporarily, and use the
The This is the output of $Temp after mounting a VHD: (Mount-DiskImage can also mount VHDs!)
Note that the attached property above is blank, despite the Mount-DiskImage command running without a hitch. Keep in mind that the $UbuntuISO variable will not stay updated either:
|
|||||||||||||||||||
|
|
Normally, if you want to do this via the command line, you need a non-interactive method. You will want to use the Thus, the command is:
Remember that if you quote the absolute path (for containing spaces and other special characters), you need to escape the quotes. To dismount an iso image, remember to quote it:
Note that we did not have to quote the command in the first case, but we do in the second, because the Also make sure to spell |
||||