'Exporting Public Folder ClientAccessPermissions to csv

So, I thought that it should be easy enough to A) Export a list of all our Public Folders B) Export a list of all our Public Folders with users who have access + access rights. And format it properly -_-

As it turned out, I was wrong, and I'm hoping someone can help me.

A) Get-PublicFolder -identity '\Legal Department' -Recurse -ResultSize Unlimited Lists all the public folders one by one as expected. Good Stuff.

Get-PublicFolder -identity '\Legal Dept' -Recurse -ResultSize Unlimited | ft -property Identity | Out-String | Out-File X:\Legal.PF.txt

This one... not so much. After around 10k-18k Public Folders it just stops writing and in one case Powershell crashed with a warning message. It was quite hilarious.

Is there a way around this? (In case you're wondering, I'm using Out-String to avoid truncation.)

B) Here I am really quite stuck. I have tried: Get-PublicFolder -identity '\Legal Dept' -Recurse -ResultSize Unlimited | FT Identity,User,AccessRights | Out-String -Width 512 | Out-File C:\Legal.PF.Perm.txt

If I just use a subset, i.e. '\Legal Dept\A\Arn', then this works fine, but the formatting is terrible with so many spaces between the columns.

So I've tried to export to csv, but with no luck.

Get-PublicFolder -identity '\Legal Dept\A\Arn' | Get-PublicFolderClientPermission | FT Identity,User,AccessRights | Export-CSV C:\Legal.PF.Perm.CSV -encoding "Unicode" -notypeinformation

Just gives me this: "ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry" "033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo", "9e210fe47d09416682b841769c78b8a3",,,,, "27c87ef9bbda4f709f6b4002fa4af63c",,,,, "27c87ef9bbda4f709f6b4002fa4af63c",,,,,

Not really much use :-/ Can anyone see what I'm doing wrong?



Solution 1:[1]

Format-Table with Export-csv will not work. You have to use Select-object instead.

Try like this :

Get-PublicFolder -identity '\Legal Dept\A\Arn' | Get-PublicFolderClientPermission | Select Identity,User,AccessRights | Export-CSV C:\Legal.PF.Perm.CSV -encoding "Unicode" -notypeinformation

Solution 2:[2]

Get-PublicFolder -Recurse | Get-PublicFolderClientPermis| select-object identity,user,{$_.AccessRights} | Export-Csv publicfoderswithpermission.csv

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Tarique Noorain
Solution 2 user4526674