Continuing this answer from How can I list directories and their sizes in command prompt?
How to list directories recursively with size using PowerShell?
Continuing this answer from How can I list directories and their sizes in command prompt?
How to list directories recursively with size using PowerShell?
How to list directories recursively with size using PowerShell?
If it's really just a recursive list you need including the file size for each file then give ForFiles a shot using the syntax below which happens to work with PowerShell as well as command line, and it has a very similar output to the Unix du -h command as you indicate you need in a comment.
Output is similar to Unix du -h but you could format further if needed.
FORFILES /S /M * /C "CMD /C ECHO @FSIZE @PATH"
PUSHD "\\servername\sharename" then run FORFILES /S /M * /C "CMD /C ECHO @FSIZE @PATH", and when it's done or on the next line run POPD and this will essentniallys change to the UNC path and run the command for you and create an arbitrary network mapping and use a drive letter for you then unmap it when done with popd
– Vomit IT - Chunky Mess Style
Nov 07 '18 at 14:03
du -h– user1970832 Sep 02 '16 at 19:20powershell -noprofile -command "ls -r|measure -s Length"but i want to print name with size. – user1970832 Sep 02 '16 at 19:23