This function is built using pinvoke and PowerShell to provide a means to list all files and folders that have a character limit greater than 260 characters. This doesn't provide a complete replacement for Get-ChildItem as it doesn't have filtering yet for attributes, but that is on my TODO list. There is an alias in the script file called GCI2 that you can use.

Related blog post: http://learn-powershell.net/2015/10/21/another-way-to-list-files-and-folders-beyond-260-characters-using-pinvoke-and-powershell/

Load function into the current console. 

PowerShell
Edit|Remove
. .\Get-ChildItem2.ps1
 

 

 

Help Text:

 

PowerShell
Edit|Remove
    <# 
        .SYNOPSIS 
            Allows for searching files beyond the 256 character limitation 
 
        .DESCRIPTION 
            Allows for searching files beyond the 256 character limitation 
 
        .PARAMETER Path 
            Path to a folder/file 
 
        .PARAMETER Filter 
            Filter object by name. Accepts wildcard (*) 
 
        .PARAMETER Recurse 
            Perform a recursive scan 
 
        .PARAMETER Depth 
            Limit the depth of a recursive scan 
 
        .PARAMETER Directory 
            Only show directories 
 
        .PARAMETER File 
            Only show files 
 
        .NOTES 
            Name: Get-ChildItem2 
            Author: Boe Prox 
            Version History: 
                1.2 //Boe Prox <20 Oct 2015> 
                    - Added additional parameters (File, Directory and Filter) 
                    - Made output mirror Get-ChildItem 
                    - Added Mode property 
                1.0 //Boe Prox 
                    - Initial version 
 
        .OUTPUT 
            System.Io.DirectoryInfo 
            System.Io.FileInfo 
 
        .EXAMPLE 
            Get-ChildItem2 -Recurse -Depth 3 -Directory 
 
            Description 
            ----------- 
            Performs a scan from the current directory and recursively displays all 
            directories down to 3 folder levels. 
    #>