Skip to content

Instantly share code, notes, and snippets.

@espio999
Last active May 2, 2023 04:52
Show Gist options
  • Save espio999/b7bbe9b0d4848322676bab0bfb695cbb to your computer and use it in GitHub Desktop.
Save espio999/b7bbe9b0d4848322676bab0bfb695cbb to your computer and use it in GitHub Desktop.
Mount ISO and change its drive letter with PowerShell - good pattern
$myISO = 'E:\ISO\Microsoft Bookshelf Basic\BSBASIC2.ISO'
Mount-DiskImage $myISO
$vol = Get-DiskImage $myISO | Get-Volume
$old_drv = $vol.DriveLetter + ':'
$new_drv = 'X:'
#WMI
#Get-WmiObject -Class Win32_Volume | Where-Object {$_.DriveLetter -eq $old_drv} | Set-WmiInstance -Arguments @{DriveLetter=$new_drv}
#CIM
Get-CimInstance -Class Win32_Volume | Where-Object {$_.DriveLetter -eq $old_drv} | Set-CimInstance -Arguments @{DriveLetter=$new_drv}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment