Public folder script

Hi,

 

I am using below script to pullout the publicfolders from CSV file and then setting the Access rights for all users on public folder as None. But I want enable logging for this script so that I can have a CSV file which will have User Identity, Public folder name\path, Last time Access (Access rights for user before running this script), New Access (Access rights for user after running this script). So please do let me know parameter I can add in this script?

 

# Add Exchange Shell...

 

If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null)

{Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010}

 

########## Script Start #####################

 

 

$AllPublicFolders = Get-Content E:\publicfolderlists.csv

 

foreach($Pf in $AllPublicFolders )

{

$a = Get-PublicFolderClientPermission -Identity "$pf"

Get-PublicFolderClientPermission -Identity "$pf" | Remove-PublicFolderClientPermission -Confirm:$false

 

 

Foreach ($b in $a)

{

Get-PublicFolderClientPermission -Identity "$pf" | Add-PublicFolderClientPermission -user $b.user -AccessRights None -Confirm:$false

 

}

}

 

 

########### Script End #####################

I want a CSV in out which will have all the parameter what I mentioned in above, so please do let me know what need to add in above script in details?
August 21st, 2015 8:54am

All you need to do is add the following command in your second foreach block...

Get-PublicFolderClientPermission -Identity $Pf |

? { $_.User -eq $b".user" } | select Identity, User, AccessRights |

Export-csv "c:\results.csv" -NTI -Append


Will.


Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 9:26am

thanks, I tried to amend above but no luck. There is no value in CSV file. It is showing blank as 0 KB size.

Please let me know full script so that I can have all the below parameter in CSV-

User Identity,

Public folder name\path,

Last time Access (Access rights for user before running this script),

New Access (Access rights for user after running this script).

August 21st, 2015 11:04am

All you need to do is add the following command in your second foreach block...

Get-PublicFolderClientPermission -Identity $Pf |

? { $_.User -eq $b".user" } | select Identity, User, AccessRights |

Export-csv "c:\results.csv" -NTI -Append


Will.


Free Windows Admin Tool Kit Click here and download it now
August 21st, 2015 1:23pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics