FSLogix / Invoke-FslShrinkDisk

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

Compacted VHD not automatically dismounting #40

Open tri-brygar opened 3 years ago

tri-brygar commented 3 years ago

Hello, We have been utilizing your script to run nightly within Task Scheduler for quite some time. Overall it is operating properly and we haven't experienced any issues, I appreciate all the hard work put into this script! Unfortunately, I'm unable to manually replicate this issue I'm reporting, but it has happened two separate times with two different user profiles on two separate days. So I wanted to ensure I logged the issue here to see how we can ensure the dismount takes place automatically.

I reviewed the Logs for this script, the 'DiskState' was logged as 'Success' and had a proper start / end time. I then reviewed the Event Logs on the server I noticed that most of the script was completed properly. But, the final dismount event was not found within 'Microsoft-Windows-VHDMP/Operational' for the user profile we had to dismount manually. I compared to the other user profiles, they generally have a dismount event logged near the time of successful compact.

What I was seeing is the Event ID '2' for removing the disk was not logged after the Event ID '51' was logged for successfully performed Compact VHD. I was only able to validate this with 1 user profile, as the other one had it's event logs overwritten by the time I reviewed. The script is running on approximately 300 profiles nightly.

For our issue, we had to login to the server and dismount the VHD manually to ensure the user could login to WVD. Below is an example Windows Event review from one of the users that were not dismounted. I changed the FSLogix Path to '\storageaccount\fslogixshare\folderpath\USER.ID_SID\Profile_User.ID.VHDX'


Reviewed Event Logs:

Information 4/19/2021 10:09:46 PM VHDMP 1 None The VHD \storageaccount\fslogixshare\folderpath\USER.ID_SID\Profile_User.ID.VHDX has come online (surfaced) as disk number 3.

Information 4/19/2021 10:09:53 PM VHDMP 2 None The VHD \storageaccount\fslogixshare\folderpath\USER.ID_SID\Profile_User.ID.VHDX has been removed (unsurfaced) as disk number 3.

Information 4/19/2021 10:09:54 PM VHDMP 1 None The VHD \storageaccount\fslogixshare\folderpath\USER.ID_SID\Profile_User.ID.VHDX has come online (surfaced) as disk number 3.


Information 4/19/2021 10:10:35 PM VHDMP 50 None Performing Compact VHD for \storageaccount\fslogixshare\folderpath\USER.ID_SID\Profile_User.ID.VHDX (target '').


Information 4/19/2021 10:10:36 PM VHDMP 51 None Successfully performed Compact VHD \storageaccount\fslogixshare\folderpath\USER.ID_SID\Profile_User.ID.VHDX.

matthias-schlimm commented 3 years ago

@JimMoyle I'm identified the same issue with many O365 Disk

image

image

Mikey-b941 commented 2 years ago

I get this too. I shrink disks using a scheduled task in the small hours, and dump the results into a CSV. Then at about 8am I run a separate scheduled task at 8am to email the results. When I noticed some stuck VHDs I modified the second scheduled tasks to find any mounted VHDs, disconnect then, and report the results as part of the results email.

If anyone would find that useful, I'll drop the code up here. It relies on having the Hyper-V tools installed on the server the script runs from, but otherwise it's just Powershell.