Skip to content

Instantly share code, notes, and snippets.

@Ryan2065
Created December 22, 2015 17:14
Show Gist options
  • Save Ryan2065/ad6aa3b43fc53c0860fd to your computer and use it in GitHub Desktop.
Save Ryan2065/ad6aa3b43fc53c0860fd to your computer and use it in GitHub Desktop.
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