Hi there, I am trying to use powershell to count the number of files/size of a directory and have come up against the dreaded max character length error...
I tried it on powershell v1 and now on v2 CTP3 and still the same issue. I understand from other threads in other forums that its a fundamental restriction in the OS due to backwards compatibility however other tools seem to have got around it eg robocopy. Is there another way of doing this which can get around the problem?
get-childitem $folder -recurse -force | measure-object -property length -sum
$folder is set to a location on the local disk
Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 26
0 characters, and the directory name must be less than 248 characters.
At C:\scripts\dfs_check.ps1:4 char:32
+ $foldersize = get-childitem <<<< $folder -recurse -force | measure-object -property length -sum
+ CategoryInfo : ReadError: (E:\Luton DR Rep...\queryprocessor:String) [Get-ChildItem], PathTooLongExcept
ion
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand
I tried it on powershell v1 and now on v2 CTP3 and still the same issue. I understand from other threads in other forums that its a fundamental restriction in the OS due to backwards compatibility however other tools seem to have got around it eg robocopy. Is there another way of doing this which can get around the problem?
get-childitem $folder -recurse -force | measure-object -property length -sum
$folder is set to a location on the local disk
Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 26
0 characters, and the directory name must be less than 248 characters.
At C:\scripts\dfs_check.ps1:4 char:32
+ $foldersize = get-childitem <<<< $folder -recurse -force | measure-object -property length -sum
+ CategoryInfo : ReadError: (E:\Luton DR Rep...\queryprocessor:String) [Get-ChildItem], PathTooLongExcept
ion
+ FullyQualifiedErrorId : DirIOError,Microsoft.PowerShell.Commands.GetChildItemCommand