This little script is a rather naive implementation of an automated ISO-image extractor. The logic is as straightforward as a simple loop that goes through all the .iso files found within the $sourcefolder and extracts the contents to a corresponding folder under $outputfolder.


param([string]$sourcefolder = "isos", [string]$outputfolder = ".", [string]$overwrite = $false)

$original_folder = $PWD
cd $sourcefolder

$list = ls *.iso | Get-ChildItem -rec | ForEach-Object -Process {$_.FullName}

foreach($iso in $list){

$folder =[System.IO.Path]::GetFileNameWithoutExtension($iso)
if((Test-Path $folder) -and $overwrite -eq $false)
{
      Write-Host "WARNING: Skipping '$folder', reason: target path already exists"
}
else
{
     if(Test-Path $folder)
     {
          rm $folder -Recurse
     }

     $mount_params = @{ImagePath = $iso; PassThru = $true; ErrorAction = "Ignore"}
     $mount = Mount-DiskImage @mount_params

     if($mount) {

         $volume = Get-DiskImage -ImagePath $mount.ImagePath | Get-Volume
         $source = $volume.DriveLetter + ":\*"
         $folder = mkdir $folder
         
         Write-Host "Extracting '$iso' to '$folder'..."
         $params = @{Path = $source; Destination = $folder; Recurse = $true;}
         cp @params
         $hide = Dismount-DiskImage @mount_params
         Write-Host "Copy complete"
    }
    else {
         Write-Host "ERROR: Could not mount " $iso " check if file is already in use"
    }
    }
}

cd $original_folder

Also note that with a couple of adjustments here and there, you could also adjust the script to process Hyper V's VHD files.

That is because the actual meat of the script is on the Mount-DiskImage CMDlet, which natively supports both, iso and VHD image formats.
Please bear in mind that this is not much more than me toying with PowerShell, I am by no means an expert on the topic.

Meaning that there could be some tricky folder structures that might not play entirely well with the script. Nevertheless, it has worked for me and I feel that it's a bit nicer than having to issue all the commands through a mighty combination of piped commands, so that's that.

A couple of areas that could definitely be improved though, would be to have a more thorough check of the input parameters and better error handling of the usual IO-related hiccups e.g. file permissions, out of disk space,  invalid characters in file name, file already mounted, etc

One last note is that I have found a little quirk when executing the script with PowerGUI - my PowerShell editor of choice - since it does not recognise any (virtual) mounted drives at runtime.
You can still edit and debug the script with PowerGUI, but for the actual extraction of files you will have to run it through the prompt.

Hope you like it!