Mount an ISO on a Physical Server running Server Core
So you need to mount an ISO on a physical server that is running Windows Server 2012 R2 Server Core? If so, how would you accomplish that task without a graphical user interface?
With PowerShell of course, specifically the Mount-DiskImage PowerShell cmdlet:
1Mount-DiskImage -ImagePath 'D:\ISO\Windows Server 2012 Trial\9200.16384.WIN8_RTM.120725-1247_X64FRE_SERVER_EVAL_EN-US-HRM_SSS_X64FREE_EN-US_DV5.ISO' -StorageType ISO -PassThru
By default nothing is returned when using the Mount-DiskImage
cmdlet and the ISO is mounted using
the next available drive letter. The PassThru
parameter was specified in the previous example but
notice there's no property that that tells us which drive letter was assigned.
Let's see if we can figure out a way to make it tell us what drive letter was assigned. Piping the
previous command to Get-Member
confirms that there isn't a drive letter property:
1Mount-DiskImage -ImagePath 'D:\ISO\Windows Server 2012 Trial\9200.16384.WIN8_RTM.120725-1247_X64FRE_SERVER_EVAL_EN-US-HRM_SSS_X64FREE_EN-US_DV5.ISO' -StorageType ISO -PassThru | Get-Member
One thing to keep in mind is that if we didn't use the PassThru
parameter to make the command
produce output, piping it to Get-Member
would generate an error because only commands that produce
output can be piped to the Get-Member
cmdlet.
Notice that piping the command to Get-Member
as shown in the previous example also gave us the
type of object that it produced which is specified after TypeName:
and before the list of
methods and properties.
Maybe there's something we can pipe the results of Mount-DiskImage
to that will tell us what drive
letter is assigned? We can use Get-Command
with the ParameterType
parameter to determine what
cmdlets accept input from MSFT_DiskImage
objects:
1Get-Command -ParameterType MSFT_DiskImage
Get-Volume looks promising, but let's verify that it accepts MSFT_DiskImage objects via pipeline input because cmdlets that accept that type of object via parameter and/or pipeline input would show up in the previous set of results.
Looking at the INPUTS
section of the help for Get-Volume
confirms that it does indeed accept
pipeline input for MSFT_DiskImage objects:
1help Get-Volume -Full
Let's pipe our Mount-DiskImage
command to Get-Volume
and see what happens:
1Mount-DiskImage -ImagePath 'D:\ISO\Windows Server 2012 Trial\9200.16384.WIN8_RTM.120725-1247_X64FRE_SERVER_EVAL_EN-US-HRM_SSS_X64FREE_EN-US_DV5.ISO' -StorageType ISO -PassThru | Get-Volume
As you can see in the previous set of results, piping Mount-DiskImage
to Get-Volume
allows us to
see what drive letter was assigned. In the previous example, drive letter E
was assigned to the
ISO image that was mounted.
µ