I\'m trying to build a comma separated list of file names in a specific folder. These files tend to have long names (they\'re test case results and the name is very descript
PowerShell v6.0.0-beta.3 and up now supports UNC paths by default; see my answer here for more information: https://stackoverflow.com/a/47046785/1599699
This seems to be a really popular question because it has been asked multiple times on this site.Anyway here are your alternatives:
Use Pinvoke
Boe Prox - Technet
Use Robocopy
Boe Prox - Technet
Use AlphaFS with Powershell V5 and V4
if you can find a computer with PowerShell v5 (windows 10 comes with PS v5) you can install a module called PSAlphaFS .
Install-Module PSAlphaFS
by default the modules from powershellgallery get installed to
C:\Program Files\WindowsPowerShell\Modules
Note:The PSAlphaFS module can also be run on a target system with PowerShell V4 but not on powershell V3.
Here is how you can find out the version of Powershell that is currently running.
$PSVersionTable.PSVersion
Once the module is in place you can then run the following command which is similar to get-childitem but without the 260 char limitation.
Get-LongChildItem -Filter *.txt -Name
It appears there is no straightforward way to handle this situation using PowerShell. To me that means PowerShell is not the right tool for this job and I'm going to use my "work-around" cmd script instead.