FSLogix / Invoke-FslShrinkDisk

This script will shrink a FSLogix Disk to its minimum possible size
MIT License
155 stars 55 forks source link

Fix disk shrink failure from missing disk image and partition objects #54

Open 4oo4 opened 2 years ago

4oo4 commented 2 years ago

This is a solution I found for when disk shrinking fails, and says it cannot get partition information: https://github.com/FSLogix/Invoke-FslShrinkDisk/issues/43#issuecomment-899825827

For some reason, Mount-DiskImage passthru will sometimes have a null value for the DiskNumber property, so this is piped into Get-DiskImage to preserve all properties.

Partition information ($partinfo) would fail silently, because when Get-Partition -DiskNumber $mountedDisk.Number -ErrorAction Stop only returns $null, but does not register as an exception, so the catch {} blocks would never fire. Instead, this is now partially handled through if statements.

Without these changes, in certain cases the script would execute, but not actually shrink any disks, and it would output that it could not get partition information in the logfile.

PyroSoul630 commented 1 year ago

THANK YOU!!!!!!

I was able to use this script to finally get all of my Profiles compressed! I would really recommend reviewing this for a new final release.

I am so grateful.

PyroSoul630 commented 2 months ago

This updated script could also be merged into the repo. It handles IFS file types with ease.


For those of you getting issue with "Cannot get partition information" due to IFS partition types: Please go to this branch to get the updated script:

https://github.com/PyroSoul630/FslShrinkDisk-2024/tree/master