Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Mount ephing drive
Function Mount-EphingDrive {
Param ($Path)
$DriveLetter=""
$MountedDrive = Mount-VHD -Path $Path -ErrorAction SilentlyContinue -PassThru
$Drives = (Get-Partition -DiskNumber $MountedDrive.DiskNumber).DriveLetter
If ($Drives.Count -gt 1) {
$LargestDrive = 0
For ($d = 0; $d -lt $Drives.Count; $d++) {
If (($Drives[$d] -ne [char]0) -and ((Get-Partition -DriveLetter $Drives[$d]).Size -gt $LargestDrive)) {
$DriveLetter = $Drives[$d]
$LargestDrive = (Get-Partition -DriveLetter $Drives[$d]).Size
}
}
} Else {
$DriveLetter = $Drives
}
return $DriveLetter
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.