1. Home
  2. Microsoft 365
  3. Intune
  4. Fix All FSLogix Profiles Using PowerShell (or Any VHDX Files)

Fix All FSLogix Profiles Using PowerShell (or Any VHDX Files)


During troubleshooting of client AVD problems, I encountered an unusual issue. Numerous entries in the FSLogix event log indicated that a volume had errors, specifically related to user VHDX profile disks. Upon further examination, I found that this was affecting about half of the user profile disks. Below are samples of the log entries from the event viewer and the FSLogix Profile log:

Additionally, users were receiving pop-up notifications indicating that drives required repair:

With hundreds of profile disks, manually identifying the affected profiles would be too labor-intensive. Therefore, I sought a method to scan and repair all disks at once. The Repair-Volume PowerShell cmdlet is suited for our needs (Repair-Volume (Storage) | Microsoft Learn). According to the description, we should utilize OfflineScanAndFix:

Before diving into how the script operates, ensure that you have the Hyper-V PowerShell module installed. Mount-VHD and Dismount-DiskImage are components of this module, which isn’t available in the PS Gallery. The simplest approach is to install the Hyper-V management tools on a workstation or server.

Next, we needed a way to locate all VHDX files within a specified share or directory, mount them, scan and repair any issues, dismount them, and proceed to the next file. The resultant script can be found on GitHub. It’s engineered to work with any VHDX file, but I specifically used it for FSLogix profile disks. Given the way FSLogix VHDXs mount in Windows, they won’t receive a drive letter, but will carry a file system label. Therefore, after mounting the VHDX, the script initially attempts to scan and repair the drive based on the file system label. If that fails, it defaults to scanning based on the drive letter. Hyper-V disks will receive a drive letter when mounted but lack a file system label. Thus, this should encompass the two primary scenarios. All outputs are logged to c:\temp\DiskRepair.log. A final note: execute this with an account that has NTFS permissions to your target directory.

Upon running the script as-is, you’ll first be prompted to specify the target directory containing the VHDX files, which will then recursively search all subdirectories.

Here’s an example of the script executing against Hyper-V VHDX files, demonstrating that there’s no File System label, prompting a mount by drive letter:

In another instance, here is the script running against an FSLogix share, where it utilizes the FileSystemLabel for the target of the repair-volume cmdlet:


Updated on July 4, 2025
Was this article helpful?

Related Articles

Leave a Comment