$FileList = Get-ChildItem -Path "$FolderPath" -Recurse | Select-Object Name, FullName
$FileArray = @()

foreach ($File in $FileList) {
    $FileName = $File.Name
    if ($FileName.length -gt 63) {
        $FilePath = $File.FullName
        $FileArray += $FilePath
        Write-Output $FileName
    }
}
$FileArray | Export-Csv -Path C:\Temp\Long-file-names.csv

I’ve tried this two or three different ways and I can’t get my desired result. I keep ending up with the value for $FileName.length in the spreadsheet instead of $FilePath which is equal to $File.FullName

3 Spice ups

yes, that’s because you strip all other properties

$File.FullName

^ this causes it. Once you export this to CSV, the only property left is ‘length’

1 Spice up

I guess with that command I thought I was telling Powershell to put “$File.FullName” into the Array. The Path is what I need in the Excel sheet, What would your suggestion be to do this differently?

try like so

$FileList = Get-ChildItem -Path "$FolderPath" -Recurse

$data = 
foreach ($File in $FileList) {
    if($file.name.Length -gt 63){
        $file
    }
}

$data | 
select-object fullname |
Export-Csv -Path C:\Temp\Long-file-names.csv
1 Spice up

look at this:

$sample1 = get-childitem "c:\" | get-member
$sample1
# vs 
$sample2 = (get-childitem "c:\").fullname | get-member
$sample2

you will see, if you use the DOT notation ($something.something) you lose all other properties and the only one left is ‘length’.
This is sometimes desired, and sometimes, well, not lol

1 Spice up