question

Marcus-9726 avatar image
0 Votes"
Marcus-9726 asked IanXue-MSFT commented

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





windows-serverwindows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Desireecaviness-1271 avatar image
0 Votes"
Desireecaviness-1271 answered Marcus-9726 commented

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Can you please kindly explain what are the difference between the command I listed in my post?

0 Votes 0 ·
IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT commented

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.

· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @IanXue-MSFT

May I know if \\?\ work with Powershell 2.0 on Windows Server 2008 service pack 2?

0 Votes 0 ·

Hello @IanXue-MSFT

I've just tried with the command but seems like not working in Windows Server 2008 SP2 with powershell 2.0. Below is the error:

117153-screenshot-2021-07-22-225108.png


0 Votes 0 ·

You may consider upgrading Window PowerShell to the latest version. Windows PowerShell 2.0 is deprecated now.

0 Votes 0 ·
Show more comments