Bulk Assigning VHDX to SSD Storage Tier With PowerShell #HyperV #RDS #VDI

2 Min. Read

In Windows Server 2012 R2 storage spaces, if there’s particular files in your environment that you absolutely know are always frequently accessed, such as a Parent VHD(X) that is used for multiple linked Child VHDs via Differencing Disks, you can specifically pin those files to the SSD tier. In this manner, Windows Server 2012 R2 doesn’t have to detect frequent access to keep the data blocks associated with those files in the fastest tier – they will always be there!

Taking a VDI deployment of pooled (non-persistent) VMs typical scenario could make sense, because you might want to map the parent VHD(X) of your master image to the SSD tier, as every pooled VM booting up reads from this file. So how can you permanently map files to a SSD or HDD storage tier?

To pin a file to the SSD tier, use the new Set-FileStorageTier PowerShell cmdlet, as follows:

Set-FileStorageTier -FilePath <PATH> -DesiredStorageTier $tier_ssd

To un-pin a file from the SSD tier, use the new Clear-FileStorageTier PowerShell cmdlet, as follows:

Clear-FileStorageTier –FilePath <PATH>

I recently rebuilt my VDI environment and I have a lot of VHD(X) files that I want to assign them to the SSD storage Tier. Once I had finished installing the operating system and had Hyper-V up and running – I wondered what is the most efficient way to get all virtual hard disks assigned would be. I ended up using PowerShell to do a bulk assign.

# Pin all VHD(X) to the SSD tier
Get-ChildItem E:\VMs -Recurse -Filter *.vhdx | %{Set-FileStorageTier –FilePath $_.FullName -DesiredStorageTier (Get-StorageTier –FriendlyName *SSD_Tier)}
Get-FileStorageTier -VolumeDriveLetter E | FT –AutoSize


# Un-Pin all VHD(X) from the SSD tier
Get-ChildItem E:\VMs -Recurse -Filter *.vhdx | %{Clear-FileStorageTier –FilePath $_.FullName}
Get-FileStorageTier -VolumeDriveLetter E | FT –AutoSize


The result of this was that in under 10 seconds, I had all of my parent virtual hard disks back and assigned on my new Hyper-V server SSD tier. Neat!



How To Create a Certain Plans/Offers for Specific Tenants in Azure Stack? #AzureStack #Azure #MAS

HyperV – CSV Volumes Pause States, Event ID 5120


4 thoughts on “Bulk Assigning VHDX to SSD Storage Tier With PowerShell #HyperV #RDS #VDI”

Leave a comment...

  1. Hi there.

    I was wondering, do you know of a way to do ‘global’ like pinning? Such as all files of one extension/type being pinned to the HDD, with all other files being pinned to the SSD?

    As backwards as that may sound, there is actually a good reason for doing it. I’m using PMS (Plex Media Server) and there is an option to have thumbnails generated. Those thumbnail files (‘.bif’ extension) take up the bulk of the space. Out of 120gb to 128gb of space used by PMS for library features, over 100gb of that are the .bif files. Those files aren’t a high priority for speed, while the other files are, as it greatly improves the access speed when browsing. Having a 120gb SSD available, even if I were to only have a third of it as part of a tier, it would be more than sufficient to store all the other files.

    So, while it may seem a bit of a request of what one would usually expect, you can see there is a legitimate reason for it. So, aside from using PS scripts to pin each and every file to the SSD (that should remain there), do you know if there is a way to accomplish what I’m looking to do?

    Don’t get me wrong, despite how the above may sound, I know you didn’t design Storage Spaces. However, since you have experience with pinning multiple files, I’m sure you are likely one of the better people to ask in regards to this idea.

  2. Hello Wolfie,

    Thanks for your comment.

    Yes, you can accomplish what you are looking for but using PowerShell script only.
    This is an example:

    # Pin all *.bif file to the HDD tier
    Get-ChildItem E:\ -Recurse -Filter *.bif | %{Set-FileStorageTier –FilePath $_.FullName -DesiredStorageTier (Get-StorageTier –FriendlyName *HDD_Tier)}
    Get-FileStorageTier -VolumeDriveLetter E | FT –AutoSize

    You can schedule it to run daily to make sure that the new generated *.bif files will be pinned to the HDD tier.

    Hope that helps!

  3. So in other words, a separate entry for each .bif file? Wouldn’t it reach a point where the number of entries would hinder performance somehow?

  4. No, it’s not a separate entry for each .bif file.

    The following script will look for all .bif files that reside under the E: Drive, and then it will pin them to the HDD tier.

    # Pin all *.bif file to the HDD tier
    Get-ChildItem E:\ -Recurse -Filter *.bif | %{Set-FileStorageTier –FilePath $_.FullName -DesiredStorageTier (Get-StorageTier –FriendlyName *HDD_Tier)}
    Get-FileStorageTier -VolumeDriveLetter E | FT –AutoSize

Let me know what you think, or ask a question...

The content of this website is copyrighted from being plagiarized!

You can copy from the 'Code Blocks' in 'Black' by selecting the Code.

Please send your feedback to the author using this form for any 'Code' you like.

Thank you for visiting!