I have the below script which used to work. now it gets 90% complete and dies:
<#
.SYNOPSIS
Expand a VHD(x) by doing a VHD migrate from original to a larger one. The task will take the old VHD name, use that as
the source. Then will migrate to a temp VHD Name. Upon completion, it will ReACL the new file, then rename the old VHD and rename the New VHD to be
the same name as the original.
#>
#Create running variables
$OldVHD = Read-Host "Which VHD(x) would you like to extend? Please use full path and filename."
$OldVHD = $OldVHD.Replace("`"","")
write-host $OldVHD
$Size = Read-Host "What size (in Mbs) would you like the new VHD(x) to be?"
#Pull apart the path to path and file
$oldVHDPath = Split-Path $OldVHD -Parent
$OldVHDFile = Split-Path $OldVHD -leaf
$NewTempVHD = "$OldVHDPath\Temp-$OldVHDFile"
#Run the process to migrate VHD from old file to new file using new file size
$p = Start-Process "C:\Program Files\FSLogix\Apps\frx.exe" -ArgumentList "migrate-vhd -src $OldVHD -dest $NewTempVHD -size-mbs=$size -dynamic=1" -wait
$p.HasExited
$p.ExitCode
#ReACL the new VHD
write-host "ReACLing $OldVHD to $NewTempVHD"
Get-Acl -Path $OldVHD | Set-Acl -Path $NewTempVHD
Start-Sleep -Seconds 10
read-host "Verify that the old profile data file is not open in Computer Management on the profile server. If it is open, the next steps will fail. If failed, please rename files manually"
#Rename the old VHD to OLD-VHDFileName, then rename the NewVHD to match the old name.
Rename-Item -Path $oldVHD -NewName "$OldVHDpath\OLD-$OldVHDFile"
Rename-Item -Path $NewTempVHD -NewName $OldVHD