Correct code:
(Get-ChildItem -Recurse -Directory).FullName | ForEach-Object {fsutil.exe file setCaseSensitiveInfo $_ enable}
Explanation:
NOTE: The code in the answer assumes you're in the root of the directory tree and you want to run fsutil.exe
against all the folders inside, as it's been pointed out in the comments (thanks @Abhishek Anand!)
Get-ChildItem -Recurse -Directory
will give you list of all folders (recursively).
As you want to pass their full path, you can access it by using .FullName
[1] (or more self-explanatory | Select-Object -ExpandProperty FullName
).
Then you use ForEach-Object
to run fsutil.exe
multiple times. Current file's FullName
can be accessed using $_
(this represents current object in ForEach-Object
)[2].
Hint:
If you want more tracking of what's currently being processed you can add the following to write the path of currently processed file to the console: ; Write-Host $_
(semicolon ;
is to separate from fsutil
invocation) as it was pointed out in the comments (thanks Fund Monica's Lawsuit !)
[1] .FullName
notation works for PowerShell 3.0 and greater, Select-Object -ExpandProperty FullName
is preferred if there's a chance that lower version will be used.
[2] $_
is an alias for $PSItem
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…