Get-ChildItem "E:\FileShare" -recurse | Get-Acl -Exclude . | export-csv c:\temp\permission.csv
Export NTFS permission on Windows Server 2008 SP2 with long path name
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
2 answers
Sort by: Most helpful
-
-
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.