2

So, I've recently lost a 400GB VHDX image due to ReFS Enforced Integrity Streams (details on question How to turn ReFS “Enforced” file integrity off?).

So now I am trying to disable the Enforced option on all my other, more important, files. Millions of files, through deep directory structures that often exceed the 256 character "limit" on full path names.

But the "naive" solution Get-ChildItem -Path "X:\" -Recurse | Set-FileIntegrity -Enforce $False throws a ScriptCallDepthException.

Everywhere I search, even on Microsoft own Blogs and documentations, suggest the Get-ChildItem -Recurse command. But it is of no use in this situation.

What's the way to go, then?

1 Answers1

3

If you are hitting this limit you may not be using Powershell V3.

Try using the "trampoline" method with a stack. The script below only prints the file names, so modify it for your case.

$stack = New-Object System.Collections.Stack
#Load first level
Get-ChildItem -Path "YOUR-PATH-HERE" | ForEach-Object { $stack.Push($_) }
#Recurse
while($stack.Count -gt 0 -and ($item = $stack.Pop())) {
    if ($item.PSIsContainer)
    {
        Write-Host "Recursing on item $($item.FullName)"
        Get-ChildItem -Path $item.FullName | ForEach-Object { $stack.Push($_) }
    } else {
        Write-Host "Processing item $($item.FullName)"
    }
}
harrymc
  • 498,455