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<\/p>","upvoteCount":3,"answerCount":5,"datePublished":"2020-07-16T17:42:12.000Z","author":{"@type":"Person","name":"thoros","url":"https://community.spiceworks.com/u/thoros"},"acceptedAnswer":{"@type":"Answer","text":"
try like so<\/p>\n
$FileList = Get-ChildItem -Path \"$FolderPath\" -Recurse\n\n$data = \nforeach ($File in $FileList) {\n if($file.name.Length -gt 63){\n $file\n }\n}\n\n$data | \nselect-object fullname |\nExport-Csv -Path C:\\Temp\\Long-file-names.csv\n<\/code><\/pre>","upvoteCount":1,"datePublished":"2020-07-16T17:58:12.000Z","url":"https://community.spiceworks.com/t/im-not-getting-the-desired-output-to-my-csv/769509/4","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},"suggestedAnswer":[{"@type":"Answer","text":"$FileList = Get-ChildItem -Path \"$FolderPath\" -Recurse | Select-Object Name, FullName\n$FileArray = @()\n\nforeach ($File in $FileList) {\n $FileName = $File.Name\n if ($FileName.length -gt 63) {\n $FilePath = $File.FullName\n $FileArray += $FilePath\n Write-Output $FileName\n }\n}\n$FileArray | Export-Csv -Path C:\\Temp\\Long-file-names.csv\n<\/code><\/pre>\n
Advertisement
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<\/p>","upvoteCount":3,"datePublished":"2020-07-16T17:42:12.000Z","url":"https://community.spiceworks.com/t/im-not-getting-the-desired-output-to-my-csv/769509/1","author":{"@type":"Person","name":"thoros","url":"https://community.spiceworks.com/u/thoros"}},{"@type":"Answer","text":"
yes, that’s because you strip all other properties<\/p>\n
$File.FullName\n<\/code><\/pre>\n^ this causes it. Once you export this to CSV, the only property left is ‘length’<\/p>","upvoteCount":1,"datePublished":"2020-07-16T17:54:49.000Z","url":"https://community.spiceworks.com/t/im-not-getting-the-desired-output-to-my-csv/769509/2","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},{"@type":"Answer","text":"
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?<\/p>","upvoteCount":0,"datePublished":"2020-07-16T17:56:46.000Z","url":"https://community.spiceworks.com/t/im-not-getting-the-desired-output-to-my-csv/769509/3","author":{"@type":"Person","name":"thoros","url":"https://community.spiceworks.com/u/thoros"}},{"@type":"Answer","text":"