dir and Long UNC

by lopyeg at 2013-04-07 12:12:50

Hello powershell guys!
I tried to do some grep with Get-ChildItem d:\ -Recurse | Where-Object {$.Length -gt 1024MB}
and i’ve got issue:
Get-ChildItem : 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.
i googled on this error - nothing got
i tried \?\D:\ - got an error
i tried to divide long url and fix them in file? but error appeared earlier than IF ))
Get-ChildItem d:\ -Recurse | Where-Object {$
.Length -gt 1024MB} |<br>%{if ($_&#46;fullname&#46;length -lt 260) {
Select-Object Name, @{Name="SizeInMB" ;Expression={$.Length / 1MB}}, |<br>add-content greater1GBs&#46;txt }
else {Select-Object Name, @{Name="Path";Expression={$
.directory} | add-content 260UNC.txt }}}

Could i walk this problem around?
Thank you for a help!!!
by lopyeg at 2013-04-07 12:17:26
it seems only robocopy could help
by happysysadm at 2013-04-08 02:45:16
Yes, Robocopy is a solution as stated by Boe Prox: http://learn-powershell.net/2013/04/01/list-all-files-regardless-of-260-character-path-restriction-using-powershell-and-robocopy/

Otherwise check my script there that uses [system.IO.Directory]::GetFiles and [system.IO.Directory]::GetDirectories: http://www.happysysadm.com/2013/04/finding-paths-that-exceed-maxpath-with.html