First, lets try to create a folder with a 260 character name:
$Folder = "12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890" $Folder.Length New-Item -ItemType Directory -Path h: -Name $Folder
This will result in "260" followed by this error:
New-Item : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
At line:1 char:1
+ New-Item -ItemType Directory -Path h: -Name $Folder
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : WriteError: (H:\123456789012...678901234567890:String) [New-Item], PathTooLongException
+ FullyQualifiedErrorId : CreateDirectoryIOError,Microsoft.PowerShell.Commands.NewItemCommand
Ok, we now know that the full path must be shortar than 260 characters.
Lets try again with 213 characters in the full path, that is below the path limit.
First we set the variable for the folder name, and then measure how many characters we got.
$Folder = "12345678901234567890123456789012345678901234567189012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456790123456789012345" $Folder.Length
Then we do the same for for the file.
$File = "12345678901234567890.txt" $File.Length
If we add the characters needed for the full path, drive letter + :\ is 3, and we need a backslash between the folder and file, that sums 4.
4 + $Folder.Length + $File.Length
Lets create the test-folder and file
New-Item -ItemType Directory -Path h: -Name $Folder New-Item -ItemType File -Path "H:\$Folder" -Name $File $FileToSet = (Get-ChildItem -Path h:\$Folder).FullName $FileToSet.Length
Now lets try the powershell commands to set/clear DesirerStorageTierClass:
Test-Path $FileToSet Set-FileStorageTier -FilePath $FileToSet -DesiredStorageTierClass Capacity Clear-FileStorageTier -FilePath $FileToSet
Lets do this all over, but we'll add a character to our file name.
$File = "123456789012345678901.txt" $File.Length
After we create the folder and file we check the path length again:
$FileToSet.Length
Now lets try the powershell commands to set/clear DesirerStorageTierClass:
Test-Path $FileToSet
Now lets run the Set-FileStorageTier command:
Set-FileStorageTier -FilePath $FileToSet -DesiredStorageTierClass Capacity
Set-FileStorageTier : Invalid Parameter
Activity ID: {284aa8c7-35f3-460f-9980-6897ad86f43d}
At line:1 char:1
+ Set-FileStorageTier -FilePath $FileToSet -DesiredStorageTierClass Cap ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (StorageWMI:ROOT/Microsoft/...FileStorageTier) [Set-FileStorageTier], CimException
+ FullyQualifiedErrorId : StorageWMI 5,Set-FileStorageTier
Clear-FileStorageTier -FilePath $FileToSet
Clear-FileStorageTier : Invalid Parameter Activity ID: {ff02b437-b439-4952-a271-a8dff5c6be13} At line:1 char:1 + Clear-FileStorageTier -FilePath $FileToSet + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (StorageWMI:ROOT/Microsoft/...FileStorageTier) [Clear-FileStorageTier], CimException + FullyQualifiedErrorId : StorageWMI 5,Clear-FileStorageTier
What have we learned from this?
The commands to set or clear a file to a desired storage tier class does not support file paths longer than 213 characters. Why is this? I have no idea!
I've search for some documentation regarding storage spaces maximum path lenghts but cannot find anything that says there is a different length limit while using a tierd storage space virtual disk.
If anyone uses tiered storage spaces virtual disks on a Windows Server-version, it would be very interesting to know if the same limit applies to the server version as on Windows 10.