Export NTFS permission on Windows Server 2008 SP2 with long path name

Marcus Wong Theen Nam 1,111 Reputation points
2021-07-22T08:16:39.643+00:00

Hi,

I have a Windows Server 2008 SP2 file server and I would like to export the NTFS permission of all file shares from the server using below powershell command:

Get-ChildItem "E:\FileShare" -recurse | Get-Acl -Exclude *.* | export-csv c:\temp\permission.csv

Inside this FileShare folder there are some folder structures like (below is only one of the example, there are many other folder with this kind of long path name):

E:\FileShare\folder1\1. folder name long\2. long long folder name\3. very long folder name here\4. long path folder namexxxxxxxxxxx

Due to this, when I execute the above powershell command I receive the error:

Get-ChildItem: Could not find a part of the path "E:\FileShare\folder1\1. folder name long\2. long long folder name\3. very long folder name here\4. long path folder namexxxxxxxxxxx"

Anyway that I could modify the command to export out all shared folder NTFS permission under E drive without hitting the long path name error again? The powershell version is 2.0

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
13,112 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,532 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Anonymous
    2021-07-22T08:49:56.973+00:00

    Get-ChildItem "E:\FileShare" -recurse | Get-Acl -Exclude . | export-csv c:\temp\permission.csv


  2. Ian Xue 37,106 Reputation points Microsoft Vendor
    2021-07-22T10:10:26.583+00:00

    Hi,

    Please try prepending "\?\" to the path.

    Get-ChildItem "\\?\E:\FileShare" -recurse | Get-Acl -Exclude *.* | export-csv c:\temp\permission.csv  
    

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.