FunctionsToExport/Function_Dismount-VHDChain.ps1
Function Dismount-VHDChain { [CmdletBinding()] Param( [Parameter(ValueFromPipeline)] [ValidateScript({ $Item = $_ | Get-Item -ErrorAction SilentlyContinue if (-not $Item) { throw 'Item ("{0}") does not exist' -f $_ } elseif ($Item.Attributes -notmatch "Directory") { throw 'Item ("{0}") is not a directory' -f $_ } $true } )] [string]$Location = $PWD, [ValidateNotNullOrEmpty()] [string]$Name = "VHDChain", [int]$Index = -1, [switch]$Passthru ) $Chain = Get-VHDChain -Name $Name -Location $Location $Splat = @{ Path = $Chain[$Index].Path Passthru = $Passthru } Dismount-VHD @Splat } |