Resize-UserProfileDisk
Resize-UserProfileDisk copied to clipboard
Defrag gives error "The given volume path is invalid. (0x89000001)"
whever I do a single Vhdx file with -defrag
option I get this error:
The given volume path is invalid. (0x89000001)
eg Resize-UserProfileDisk -SingleVhdxFile "E:\UPDs\UVHD-S-1-5-21-3615657673-3089639132-939047325-6172.vhdx" -defrag
Actually $DriveLetter = ($MountResult | Get-Disk | Get-Partition).DriveLetter
is not working properly.
Pass through should be added at least for $MountResult
like $MountResult = Mount-DiskImage $vhdx -PassThru
But even then DevicePath
is empty (seems more like a bug in PowerShell).
Assuming you don't have any virtual disks mounted a quick fix could be changing the code to:
I changed $MountResult = Mount-DiskImage $vhdx -PassThru
and $DriveLetter = (Get-Disk | ?{$_.FriendlyName -eq "Msft Virtual Disk"} | Get-Partition).DriveLetter
if ($defrag) {
Write-Log -severity Information -message "Defrag parameter detected. Script wil defragging the VHDX-files. Script wil use the defrag.exe with the /x switches."
foreach ($vhdx in $vhdxArray) {
try {
Write-Log -severity Information -message " "
Write-Log -severity Information -message "Defrag: Try to mount VHDX-file $vhdx..."
$MountResult = Mount-DiskImage $vhdx -PassThru
Start-Sleep -Seconds 15
Write-Log -severity Information -message "Defrag: Try to mount VHDX-file $vhdx... Done"
}
Catch {
$error.clear()
$errormessage = $_.exception.message
Write-Log -severity Information -message "Defrag: Try to mount VHDX-file $vhdx... Failed. Error: $errormessage"
return
}
try {
Write-Log -severity Information -message "Defrag: Checking for driveletter mounted $vhdx..."
$DriveLetter = (Get-Disk | ?{$_.FriendlyName -eq "Msft Virtual Disk"} | Get-Partition).DriveLetter
Write-Log -severity Information -message "Defrag: Checking for driveletter mounted $vhdx... Done. Detected driveletter: $Driveletter"
}
Hello,
I have same problem. :(
The fix won't work for me.
Do you have a another solution ?
Thank you
Hi,
the fix helped with defrag but sdelete still mentions that the driveletter is wrong or missing.