Last active
May 2, 2023 04:52
-
-
Save espio999/b7bbe9b0d4848322676bab0bfb695cbb to your computer and use it in GitHub Desktop.
Mount ISO and change its drive letter with PowerShell - good pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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