Public/Dismount-FsLogixVHD.ps1
<#
.SYNOPSIS Dismounts an FsLogix VHD file. .DESCRIPTION The Dismount-FsLogixVHD function dismounts a specified VHDX file. .PARAMETER VhdxPath The path to the VHDX file that needs to be dismounted. .EXAMPLE Dismount-FsLogixVHD -VhdxPath "C:\VHDs\example.vhdx" Attempts to dismount the VHDX located at "C:\VHDs\example.vhdx". .NOTES Requires administrative privileges to run. #> Function Dismount-FsLogixVHD { [CmdletBinding(SupportsShouldProcess = $True)] Param ( [Parameter(Mandatory = $True)] [string]$VhdxPath ) Process { if ($PSCmdlet.ShouldProcess($VhdxPath, "Dismount VHDX")) { try { Dismount-VHD -Path $VhdxPath -ErrorAction Stop Write-Verbose "VHDX has been dismounted successfully." } catch { Write-Error "Failed to dismount VHDX: $($_.Exception.Message)" } } } } |