none
What is the point of NoDriveLetter in Mount-Diskimage? RRS feed

  • Question

  • I tried to use NoDriveLetter to mount a disk image to an empty folder. A straightforward task in DiskManager, but turned out to be more complicated in PowerShell.

    Mount-DiskImage will return a CimInstance object, but of the MSFT_DiskImage type. The only way I know to assign a path to a mount is Add-PartitionAccessPath. How can I tell Add-PartitionAccessPath which disk to mount? Mount-DiskImage will not give me an Id, DiskNumber or DriveLetter (with NoDriveLetter at least). That leaves InputObject as the only choice. InputObject should be a CimInstance object, but of the MSFT_Partition type.

    I have tried:

    PS > $Image = Mount-DiskImage -ImagePath D:\Images\en_office_professional_plus_2010_with_sp1_x86_x64_dvd_730330.iso -NoDriveLetter -PassThru
    
    PS > $Image | select-object -Property * 
    
    Attached              : False
    BlockSize             : 0
    DevicePath            : 
    FileSize              : 2647570432
    ImagePath             : D:\Images\en_office_professional_plus_2010_with_sp1_x86_x64_dvd_730330.iso
    LogicalSectorSize     : 2048
    Number                : 
    Size                  : 2647570432
    StorageType           : 1
    PSComputerName        : 
    CimClass              : ROOT/Microsoft/Windows/Storage:MSFT_DiskImage
    CimInstanceProperties : {Attached, BlockSize, DevicePath, FileSize...}
    CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

    I haven't found a way to feed that to Add-PartitionAccessPath. I even tried:

    $Volume = Get-Volume -DiskImage $Image
    $Partition = Get-Partition -Volume $Volume
    $Source = Add-PartitionAccessPath -InputObject $Partition -AccessPath $MntDir -PassThru

    but Get-Partition can't see the volume if it isn't mounted.

    This brings me back to the question in the title. What is the intended use of NoDriveLetter?

    Am I overlooking something obvious? (It wouldn't be the first time..)

    Wednesday, August 13, 2014 2:25 PM

Answers

  • Just in case someone stumbles on this..

    I did find a solution. Sam's suggestion helped me to find the direction. I had to find the WMI object of the volume:

    $Image = Mount-DiskImage -ImagePath D:\Images\en_office_professional_plus_2010_with_sp1_x86_x64_dvd_730330.iso -NoDriveLetter -PassThru $Vol = Get-Volume -DiskImage $Image $Drive = Get-WmiObject win32_volume -Filter "Label = '$($Vol.FileSystemLabel)'" -ErrorAction Stop $Drive.AddMountPoint('C:\mount')


    Friday, August 15, 2014 10:15 PM

All replies

  • You will need to use WMI to set/change drive letter on a volume as in:

    $Image = Mount-DiskImage -ImagePath D:\Images\en_office_professional_plus_2010_with_sp1_x86_x64_dvd_730330.iso -NoDriveLetter -PassThru
    $Volume = Get-Volume -DiskImage $Image
    $Drive = Get-WmiObject win32_volume -Filter "Label = '$($Volume.FileSystemLabel)'"
    $Drive.DriveLetter = "m:"
    $Drive.put()


    Sam Boutros, Senior Consultant, Software Logic, KOP, PA http://superwidgets.wordpress.com (Please take a moment to Vote as Helpful and/or Mark as Answer, where applicable)

    Wednesday, August 13, 2014 3:35 PM
  • Thanks for your thoughts!

    My point is, I don't want to assign a drive letter at all. I want to access the image via a temporary folder. I am writing a script that will mount a series of ISO-images and copy a few files off of each.

    If I leave out the NoDriveLetter from the Mount-DiskImage, I will get an mounted disk with a letter and easy access, that is not a problem.

    I was just wondering what is the whole point of the option. Why would someone want to mount a disk image without any way of accessing it? Certainly someone had an idea when s/he wrote the code for the option.

    Sam, I played with the Get-WmiObject in your example, but it returns a System.Management.ManagementObject that Add-PartitionAccessPath can't digest. It wants a CimInstance of MSFT_Partition flavor, which is in line with the name of cmdlet.


    • Edited by PetriRiihikallio Wednesday, August 13, 2014 4:55 PM clarify
    • Proposed as answer by FSLogixKev Wednesday, June 20, 2018 10:10 PM
    Wednesday, August 13, 2014 4:54 PM
  • Just in case someone stumbles on this..

    I did find a solution. Sam's suggestion helped me to find the direction. I had to find the WMI object of the volume:

    $Image = Mount-DiskImage -ImagePath D:\Images\en_office_professional_plus_2010_with_sp1_x86_x64_dvd_730330.iso -NoDriveLetter -PassThru $Vol = Get-Volume -DiskImage $Image $Drive = Get-WmiObject win32_volume -Filter "Label = '$($Vol.FileSystemLabel)'" -ErrorAction Stop $Drive.AddMountPoint('C:\mount')


    Friday, August 15, 2014 10:15 PM