All,

If anyone can help, I'd much appreciate it.

I'm picking up where I left off some time ago in auditing our file server.

I used robocopy to generate a list of files for each drive on our file
server - all told over 10.3m lines, massaged the output (with findstr)
to break it up by drive letter and to remove directories and things
like $recycle.bin and 'system volume', then further massaged the
output to remove the extraneous robocopy markings. I had to break it
into smaller files by partition because processing the file in
powershell overran RAM on a 16g machine.

I then took each line (which looked like, e.g.
i:\somedirectory\otherdirectory\file), then prepended '\\?\' to each
line), because some number of the files have path lengths greater than
260 characters, and I'm hoping that using this specification will
allow access to those files without adding funky 3rd party tools.

So, I've ended up with a set of text files that have many lines that
look like this:
     \\?\i:\somedirectory\otherdirectory\file

What I'm trying to do is illustrated by the following, but I'm getting
no output from it - it just returns without any output after a few
moments.

     $files = get-content c:\batchfiles\file-i.txt
     foreach ( $file in $files )
     {
        get-childitem $file | select length, fullname
     }


However, if I strip the '\\?\' from each line, it does what I want -
but of course the script fails as soon as it encounters a file that
has a name/directory specification that exceeds the Win32 API limit.

I've tried surrounding the string with both double and single quotes,
and still no joy.

A simpler example tells the tale:

This works, except for long file names:
     gci i:\somedirectory\otherdirectory\file

These fail silently:
     gci \\?\i:\somedirectory\otherdirectory\file
     gci "\\?\i:\somedirectory\otherdirectory\file"
     gci '\\?\i:\somedirectory\otherdirectory\file'

These fail with an error:
     gci "\\\\?\\i:\somedirectory\otherdirectory\file"
     gci '\\\\?\\i:\somedirectory\otherdirectory\file'

The error is:
Get-ChildItem : Cannot retrieve the dynamic parameters for the cmdlet.
Cannot process argument because the value of
argument "path" is not valid. Change the value of the "path" argument
and run the operation again.
At line:1 char:1
+ gci "\\\\?\\i:\CFRemoteImages\Air Canada Montreal STOC.vhd" | select
length, ful ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-ChildItem],
ParameterBindingException
    + FullyQualifiedErrorId :
GetDynamicParametersException,Microsoft.PowerShell.Commands.GetChildItemCommand


================================================
Did you know you can also post and find answers on PowerShell in the forums?
http://www.myitforum.com/forums/default.asp?catApp=1

Reply via email to