Exchange 2010 Get-PublicFolderStatistics Import-Csv Script Error

I'm trying to build a script that imports a list of Identities into the Get-PublicFolderStatistics cmdlet that were generated from the Get-PublicFolder cmdlet. However, each time I do this I'm getting the error below. How do I input the Identity variable into the script below so it will not get that error? I don't think it is permissions related as I'm an OA. Also, in the csv folder that I created all the identities are in the format \SomeFolder\SomeSubFolder, and I'm not sure why the output gives the identity as "@{Identity=\SomeFolder\SomeSubFolder}.Identity". Any help would be greatly appreciated. Thank you.

SCRIPT

Import-Csv "C:\Users\SomeUser\Desktop\Some_Identities.csv" | foreach-object {Get-PublicFolderStatistics -Identity "$_.Identity" | Select Name,LastAccessTime,LastModificationTime,TotalItemSize | Export-Csv "C:\Users\SomeUser\Desktop\PublicFolderInfo.csv"}

ERROR

No existing 'PublicFolderEntry' matches the following Identity: '@{Identity=\SomeFolder\SomeSubFolder}.Identity'. Make sure that you specified the correct 'PublicFolderEntry' Identity and that you have the necessary permissions to view 'PublicFolderEntry'.
    + CategoryInfo          : NotSpecified: (0:Int32) [Get-PublicFolderStatistics], MapiOperationException
    + FullyQualifiedErrorId : D7E582BB,Microsoft.Exchange.Management.MapiTasks.GetPublicFolderStatistics

April 28th, 2015 7:19am

This would be the correct way to do that.

Import-Csv C:\Users\SomeUser\Desktop\Some_Identities.csv | 
   foreach-object{
       Get-PublicFolderStatistics -Identity $_.Identity
   } | 
   Select Name,LastAccessTime,LastModificationTime,TotalItemSize | 
   Export-Csv C:\Users\SomeUser\Desktop\PublicFolderInfo.csv

Try not to quote everything in sight.  As you can see it can cause errors.

Free Windows Admin Tool Kit Click here and download it now
April 28th, 2015 7:48am

jrv:

  Your solution worked, however, prior to seeing your response I found another way as well. Below is a script that worked just as well as yours. Thank you so much for your help.

$publicfolderinput = Import-Csv C:\Users\SomeFolder\Desktop\PublicFolder_Input.csv

ForEach-Object ($publicfolderinput.Identity) {Get-PublicFolderStatistics -Identity $publicfoderinput.Identity -ResultSize Unlimited | Select FolderPath,Name,LastAccessTime,LastModificationTime,TotalItemSize | Export-Csv "C:\Users\SomeFolder\Desktop\PublicFolderReview_Output.csv"}

April 29th, 2015 10:43am

   I apologize for not including this in my first post. The purpose of this task was to pull all Public Folder information for administrators to begin a clean up or migration process for users that have Public Folders. The administrators requested that a spreadsheet be created that gave the names of all Public Folders and their sub folders, the owners listed for each folder, The last time the folders were accessed, the last time the folders were modified and the size of each folder. What I did, and this may have been a round about way of completing this task; was to first use the [Get-PublicFolders -Identity "\" -Recurse | Export-Csv <FileName>.csv] command to pull the Identity variable of all PublicFolders so that I could then use that CSV to import the Identity variable into the [Get-PublicFolderStatistics] command and not have to enter each of the 2000+ Identities in one at a time. I hope this helped clear up the purpose of my question. In order to get the permissions I used a script that was on MukutDasBlogs (http://blogs.technet.com/b/mukutdas/archive/2014/06/27/export-public-folder-permission-in-exchange-2010.aspx), as shown below, to pull all the permissions for each folder. From there I simply filtered the Rights column for the Owner objects and copied that information off to my other output csv along with all the other data.

Get-PublicFolderClientPermission:

Get-PublicFolder \ -Recurse | Get-PublicFolderClientPermission | Select-Object Identity,@{Expression={$_.User};Label="User";},@{Expression={$_.AccessRights};Label="AccessRights";} | Export-Csv C:\PublicFolderClientPermission.csv

Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 10:46am

jrv:

  Your solution worked, however, prior to seeing your response I found another way as well. Below is a script that worked just as well as yours. Thank you so much for your help.

$publicfolderinput = Import-Csv C:\Users\SomeFolder\Desktop\PublicFolder_Input.csv

ForEach-Object ($publicfolderinput.Identity) {Get-PublicFolderStatistics -Identity $publicfoderinput.Identity -ResultSize Unlimited | Select FolderPath,Name,LastAccessTime,LastModificationTime,TotalItemSize | Export-Csv "C:\Users\SomeFolder\Desktop\PublicFolderReview_Output.csv"}

  • Marked as answer by XR2K 13 hours 2 minutes ago
April 29th, 2015 2:43pm

jrv:

  Your solution worked, however, prior to seeing your response I found another way as well. Below is a script that worked just as well as yours. Thank you so much for your help.

$publicfolderinput = Import-Csv C:\Users\SomeFolder\Desktop\PublicFolder_Input.csv

ForEach-Object ($publicfolderinput.Identity) {Get-PublicFolderStatistics -Identity $publicfoderinput.Identity -ResultSize Unlimited | Select FolderPath,Name,LastAccessTime,LastModificationTime,TotalItemSize | Export-Csv "C:\Users\SomeFolder\Desktop\PublicFolderReview_Output.csv"}

  • Marked as answer by XR2K Thursday, April 30, 2015 6:06 PM
Free Windows Admin Tool Kit Click here and download it now
April 29th, 2015 2:43pm

jrv:

  Your solution worked, however, prior to seeing your response I found another way as well. Below is a script that worked just as well as yours. Thank you so much for your help.

$publicfolderinput = Import-Csv C:\Users\SomeFolder\Desktop\PublicFolder_Input.csv

ForEach-Object ($publicfolderinput.Identity) {Get-PublicFolderStatistics -Identity $publicfoderinput.Identity -ResultSize Unlimited | Select FolderPath,Name,LastAccessTime,LastModificationTime,TotalItemSize | Export-Csv "C:\Users\SomeFolder\Desktop\PublicFolderReview_Output.csv"}

  • Marked as answer by XR2K Thursday, April 30, 2015 6:06 PM
April 29th, 2015 2:43pm

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

Other recent topics Other recent topics