0

This question is an extension of PowerShell - searching for existing files generates empty output.

I'm having trouble capturing long file path names with AlphaFS. I've looked at related AlphaFS questions but I can't see how they address my issue: The code below is intended to capture files in a $source directory into a .csv, including those with paths that are longer than 260 characters. However, the output I get in TestFileLocations.csv consists of 1 line that reads

IsReadOnly|"IsFixedSize"|"IsSynchronized"|"Keys"|"Values"|"SyncRoot"|"Count"

followed by 125060 lines that read

False|"False"|"False"|"System.Collections.Hashtable+KeyCollection"|"System.Collections.Hashtable+ValueCollection"|"System.Object"|"1"

PS Code

[System.Reflection.Assembly]::LoadFrom('C:\AlphaFS\AlphaFS\lib\net35\AlphaFS.dll')
$searchFiles = Import-CSV 'C:\Data\SCRIPTS\PS1\TestFindFile.csv' -Header ("Name")
$source = 'C:\Data\Scripts'
$outputPath = 'c:\data\scripts\ps1\TestFileLocation.csv'

    $searchFiles |  ForEach-Object {
        $files = [Alphaleonis.Win32.Filesystem.Directory]::EnumerateFileSystemEntries($source,'*',[System.IO.SearchOption]::AllDirectories) 
        $files | ForEach-Object { [PSCustomObject] @{FileName = $_} }
    } | export-csv -notypeinformation -delimiter '|' -path $outputPath

My TestFindFile.csv contains only 4 lines pertaining to 3 existing files that should be found by the code. The last file has 262 characters:

Name
123.pdf
321.pdf
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.txt

I'm on Windows 7. Any pointers would be appreciated.

Community
  • 1
  • 1
val
  • 1,629
  • 1
  • 30
  • 56

1 Answers1

1

I wrapped Alphafs into a PS module which you can find on the PowerShell Gallery here.

Since it is a module I cannot post the whole code but can include a link from where you can download it.

PSAlphaFS

Once you have the module you can do something like this :

 Get-LongChildItem -path yourpath | export-csv output.csv -notype
Tony Hinkle
  • 4,706
  • 7
  • 23
  • 35
Kiran Reddy
  • 2,836
  • 2
  • 16
  • 20
  • finally got it to work. I was having compounding issues; seems i had to update to https://www.microsoft.com/en-us/download/details.aspx?id=50395 and also connect outside of my company's firewall as it wasn't letting me install PSAlphaFS. – val Jun 29 '16 at 23:44
  • great to hear that! – Kiran Reddy Jul 01 '16 at 09:34
  • do you know if PSAlphaFS conflicts with -ErrorAction SiltentlyContinue and/or -exclude ? I have posted here http://stackoverflow.com/questions/38131238/powershell-exclude-directory-from-search (see my second last comment) – val Jul 01 '16 at 09:38