Closed scriptingstudio closed 1 year ago
Can you give me an example I can duplicate?
Well, yesterday I tried to analyze the corporate file storage, and in order not to reinvent the wheel, I remembered your script. Our storage has a lot of long filenames and the script was throwing errors. Then I searched with the prefix \\?\UNC\
and the errors gone. In order not to remember every time about prefixes I added a new parameter.
https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=registry
EXAMPLES
\\?\C:\Windows
\\?\UNC\server\share
offtopic
line 94
$data = $($d.GetFiles()).Where({$_.attributes -notmatch "hidden"})
I believe it should be @
instead of $
$data = @($d.GetFiles()).Where({$_.attributes -notmatch "hidden"})
You say, There appears to be a bug with the array list in Windows PowerShell.
Did you try [system.collections.generic.list[object]]
?
Why are you declaring _enumdir
function inside of cycle and not in begin
block?
I haven't looked at this code in awhile. I think I wrote much of it as I visualized the process. Probably does make sense to move the private _enumdir function. It is only used in Windows PowerShell 5.1 but it won't hurt to define it.
I switched to System.Collections.Generic.List[]
instead of the array.
I have a better understanding of the long file name format. I will need to treat the path as a literal path.
@scriptingstudio Would it make more sense to use add a parameter set and introduce -LiteralPath
?
You have already mixed literal
and regex
notation by using -literalpath
parameter in Convert-Path
. You will have to introduce parameter sets or at least to somehow parameterize Convert-Path
selecting path/literalpath that can overcomplicate your code.
My primary goal was to scan a storage having long file names and I added the parameter. It worked perfectly.
I'm realizing now how much I've kludged together in this command.
The command is not the most elegant code I've ever written, but it works. I have published v2.46.0 to the PowerShell Gallery with a revised version of Get-FolderSizeInfo. I don't have an environment to test it so thoroughly let me know if this works better for you.
For my purposes it works. -EnableLongFileName
parameter works.
I forgot to add a parameter alias, EnableLn
. I'll add that in the next release.
Added the EnableLN
parameter alias in v2.47.0
Describe the request
Introduce new switch parameter, say,
-EnableLn
PowerShell version
5.1
Platform
Windows 10 Pro or Enterprise
UPDATE
missed one slash after "UNC"
$item = if ($item -match '^\\\\') {"\\?\UNC\$($item.substring(2))"} else {"\\?\$item"}