Get-DiskImage returns an error "The process cannot access the file because it is being used by another process.", if a user is logged on with the container in $Path.
You should change this to:
Write-Error $Error[0] -ErrorAction Stop
Otherwise, functions like Get-FslDisk will fail, if a container is "in use"!
https://github.com/aaronparker/FSLogix/blob/033e83561769593e77fd08aba027fa81853ef422/Modules/Fslogix.Powershell.Disk/Private/Get-DiskInformation.ps1#L16
Get-DiskImage returns an error "The process cannot access the file because it is being used by another process.", if a user is logged on with the container in $Path.
You should change this to: Write-Error $Error[0] -ErrorAction Stop
Otherwise, functions like Get-FslDisk will fail, if a container is "in use"!