HOWTO compact vhd/vhdx Hyper-V files

It happened that the usual compact disk from Hyper-V Console doesn’t seem to be effective on one of my .vhdx file.

Looking around on the web, I discovered that it is a quite common problem.

The solution is to open a Powershell window with administrative access rights, and use the following command:

optimize-vhd <offline Hyper-V disk file> -mode full

For further details about this command, jump here on MS site.