Use Windows PowerShell to count and list total number of items in Folders E-Mail in Office Outlook?

I have the need to generate a list of all outlook folders and the total number of items listed beside each folder name. I thought I could simply modify the script from " http://blogs.technet.com/b/heyscriptingguy/archive/2009/01/26/how-do-i-use-windows-powershell-to-work-with-junk-e-mail-in-office-outlook.aspx
" regarding the total number of items in the junk folder but no luck.
I thought I could just simply duplicate line 6 of the aforementioned script
"$folder = $namespace.getDefaultFolder($olFolders::olFolderJunk) " and change the folder name but getting the "Method invocation failed because [Microsoft.Office.Interop.Outlook.OlDefaultFolders] does not contain a method
named 'olFolder'.
At line:7 char:1
+ $folder = $namespace.getCurrentFolder($olFolders::olFolder("Design Engineering S ...
I've found a way to export a list of all these folders using exportoutlookfolders.vbs to a txt file but doesn't include total number of items.
Looking for any pointers on how to make this work. Don't expect anyone to write it for me but I am still learning PS. Would be great to find a way to import all of these folder and subfolder names into the script. Will be appreciative of any advice though.
There's an enormous amount of Outlook folders.
Outlook 2013
Windows 8
Thanks,
Barry

Since I am not and administrator, but an end user, I do not have access to the Get-Mailxxxx commandlets to make this really easy and had to do this long hand.
  The following will pull folder.name, folder.items.count, and sum the total size of each folder's items for all folders and their subs. 
Just one warning, the summation can take some time with a large PST file since it needs to read every email in the PST. 
There is also some minor formatting added to make the results a little more readable.
$o
= new-object
-comobject outlook.application 
$n
= $o.GetNamespace("MAPI") 
$f
= $n.GetDefaultFolder(6).Parent 
$i
= 0
$folder
= $f
# Create a function that can be used and then re used to find your folders
Function
Get-Folders()
{Param($folder)
 foreach($folder
in $folder.Folders)   
{$Size =
0
$Itemcount
= 0
$foldername
= $folder.name
#Pull the number of items in the folder
$folderItemCount
= $folder.items.count
#Sum the item (email) sizes up to give the total size of the folder
foreach ($item
in $folder.Items)
{$Itemcount
= $Itemcount
+ 1
$Size =
$Size +
$item.size
Write-Progress -Activity ("Toting size of "
+ $foldername
+ " folder.")
-Status ("Totaling size of "
+ $Itemcount
+ " of "
+ $folderItemCount
+ " emails.")
-PercentComplete ($itemcount/$folderItemCount*100)
# just a little formating of the folder name for ease of display
While($foldername.length
-le 19){$foldername
= $foldername
+ " "}
#Write the results to the window
Write-Host ("-folder "
+ $foldername
+ "  
-itemcount " +
"{0,7:N0}" -f
$folderItemCount +
"   -size " +
"{0,8:N0}" -f ($size/1024)
+ " KB")
#If the folder has a sub folder then loop threw the Get-Folders function.
#This two lines of code is what allows you to find all sub folders, and
#sub sub folders, and sub sub sub for as many times as is needed.
If($folder.folders.count
-gt 0)
{Get-Folders($folder)}
get-folders($folder)

Similar Messages

  • [Forum FAQ] How to find and replace text strings in the shapes in Excel using Windows PowerShell

    Windows PowerShell is a powerful command tool and we can use it for management and operations. In this article we introduce the detailed steps to use Windows PowerShell to find and replace test string in the
    shapes in Excel Object.
    Since the Excel.Application
    is available for representing the entire Microsoft Excel application, we can invoke the relevant Properties and Methods to help us to
    interact with Excel document.
    The figure below is an excel file:
    Figure 1.
    You can use the PowerShell script below to list the text in the shapes and replace the text string to “text”:
    $text = “text1”,”text2”,”text3”,”text3”
    $Excel 
    = New-Object -ComObject Excel.Application
    $Excel.visible = $true
    $Workbook 
    = $Excel.workbooks.open("d:\shape.xlsx")      
    #Open the excel file
    $Worksheet 
    = $Workbook.Worksheets.Item("shapes")       
    #Open the worksheet named "shapes"
    $shape = $Worksheet.Shapes      
    # Get all the shapes
    $i=0      
    # This number is used to replace the text in sequence as the variable “$text”
    Foreach ($sh in $shape){
    $sh.TextFrame.Characters().text  
    # Get the textbox in the shape
    $sh.TextFrame.Characters().text = 
    $text[$i++]       
    #Change the value of the textbox in the shape one by one
    $WorkBook.Save()              
    #Save workbook in excel
    $WorkBook.Close()             
    #Close workbook in excel
    [void]$excel.quit()           
    #Quit Excel
    Before invoking the methods and properties, we can use the cmdlet “Get-Member” to list the available methods.
    Besides, we can also find the documents about these methods and properties in MSDN:
    Workbook.Worksheets Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff835542(v=office.15).aspx
    Worksheet.Shapes Property:
    http://msdn.microsoft.com/en-us/library/office/ff821817(v=office.15).aspx
    Shape.TextFrame Property:
    http://msdn.microsoft.com/en-us/library/office/ff839162(v=office.15).aspx
    TextFrame.Characters Method (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff195027(v=office.15).aspx
    Characters.Text Property (Excel):
    http://msdn.microsoft.com/en-us/library/office/ff838596(v=office.15).aspx
    After running the script above, we can see the changes in the figure below:
    Figure 2.
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    Thank you for the information, but does this thread really need to be stuck to the top of the forum?
    If there must be a sticky, I'd rather see a link to a page on the wiki that has links to all of these ForumFAQ posts.
    EDIT: I see this is no longer stuck to the top of the forum, thank you.
    Don't retire TechNet! -
    (Don't give up yet - 13,085+ strong and growing)

  • Just FYI, new blog post "Deploy BranchCache Content and Hosted Cache Servers Using Windows PowerShell"

    Just FYI, new blog post "Deploy BranchCache Content and Hosted Cache Servers Using Windows PowerShell" at
    http://aka.ms/le85n3
    Thanks -
    James McIllece

    Great to see new BranchCache content out there!
    We created a BranchCache info page to try to get all of the relevant info into one place for V1 and 2
    http://2pintsoftware.com/microsoftbranchcache
    thanks
    Phil
    Phil Wilcock http://2pintsoftware.com @2pintsoftware

  • [Forum FAQ] "Unable to connect to the server by using Windows PowerShell Remoting" error while installing RDS roles on Server 2012 R2

    When you try to install RDS role on server 2012 R2 using standard deployment, this issue may occur (Figure 1).
    “Unable to connect to the server by using Windows PowerShell remoting”.
    Figure 1: Unable to connect to the server by using Windows PowerShell remoting
    First of all, we need to verify the configurations as it suggested:
    1. The server must be available by using Windows PowerShell remotely.
    2. The server must be joined to a domain.
    3. The server must be running at least Windows Server 2012 R2.
    4. The currently logged on user must be a member of the local Administrators group on the server.
    5. Remote Desktop Services connections must be enabled by using Group Policy.
    In addition, we need to check if the “Windows Remote Management “service is running and related firewall exceptions have been created for WinRM listener.
    To enabling PowerShell remoting, we can run this PowerShell command as administrator (Figure 2).
    Enable-PSRemoting -Force
    Figure 2: Enable PowerShell Remoting
    However, if issue persists, we need to check whether it has enough memory to work.
    By default, remote shell allots only 150 MB of memory. If we have IIS or SharePoint App pool, 150 MB of memory is not sufficient to perform the remoting task. Therefore, we need to increase
    the memory via the PowerShell command below:
    Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1000
    Then, you need to restart the server and the issue should be resolved.
    You can get more information regarding Remote Troubleshooting by below link:
    about_Remote_Troubleshooting
    If you need further assistance, welcome to post your questions in the
    RDS forum.
    Please click to vote if the post helps you. This can be beneficial to other community members reading the thread.

    i found another possible reason, this solution worked for me:
    http://oyvindnilsen.com/solution-for-powershell-remoting-error-it-cannot-determine-the-content-type-of-the-http-response-from-the-destination-computer/
    I tried to set up powershell remoting on a server and kept getting this error:
    Enter-PSSession : Connecting to remote server failed with the following error message : The WinRM client cann
    ot process the request. It cannot determine the content type of the HTTP response from the destination comput
    er. The content type is absent or invalid. For more information, see the about_Remote_Troubleshooting Help to
    pic.
    After a bit of troubleshooting I discovered that the problem was that the authentication packets was to big (over 16k), this will cause WinRM to reject the request. The reason for authentication packets getting too big can be because the user is member of very
    many security groups or in my case because of the SidHistory attribute.
    The solution was to increase the MaxFieldLength and MaxRequestBytes keys in the registry under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters
    If the keys does not exists you can create them, be sure to use the DWORD type.
    I sat MaxFieldLength to DEC value 40000 and MaxRequestBytes to DEC value 32768 and rebooted the server. Problem solved.

  • I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library.

    I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library. 
    I don't see anything in Help that shows when you already have transfered all the files over.  Why would it want to erase and sync when I already have all the music folder copied over?  I didn't have an issue when I had another technician copy from one laptop to another.  Home sharing is also on but not being recognized.

    I suspect you only migrated the media folder instead of the complete working library. Either review the transfer process and copy over the entire iTunes folder from your old profile's music folder or see Recovering your iTunes library from your iPod or iOS device.
    tt2

  • Ipod touch wont show up in usb or itunes help pages just bring me in circles.  how can i get it to show up.  I use windows xp at home and tried everything then tried a relatives computer using windows 7 and still nothing.  this is an older ipod touch

    the help pagers just bring me around in circles.  the ipod doesn't show up in system devices under the busses.  i've tried just about everything.  Im using windows xp at home and though maybe it was because of that. so went to a relatives and used a brand new lap top avus with windows 7 and it wont show up here either.  When i got the ipod a few days ago from a third party the only screen i could get to come up was a picture of a usb cord with an arrow pointing towards the itunes logo.  I downloaded i tunes and couldn't get it to change.  brought it to at&t store today they hooked it up with my usb cord to thier computer and suddenly the menu screens work and i could even get online with it yet when i try to hook it up to one of my computers it doesn't show up anywere where can i go to get this fixed and fixed quick jumping around the apple help pages have put me in a foul mood and im sick of it two days spent trying to get it to show now.  im sick of waiting around i need help asap so i can return this **** thing if it turns out it is broken somehow..which i dont think it is.

    What gen iPod (3,4?) did you buy?

  • How do you change the language of the dictionary on Safari from English (US) to (UK)? I'm using Windows 7 Home Premium and the latest version of Safari for Windows that I know of. Cheers in advance

    How do you change the language of the dictionary on Safari from English (US) to (UK)? I'm using Windows 7 Home Premium and the latest version of Safari for Windows that I know of. Cheers in advance

    92matt wrote:
    Cheers for the quick response, but do you know whow I would do that?
    Apologies I'm not the most technical of people!
    Open Regional and Language Options by clicking the Start button , clicking Control Panel, clicking Clock, Language, and Region, and then clicking Regional and Language Options.
    Lupunus

  • I use windows desktop at home and want to use Apple laptop on the go.  What do I have to do?

    I use windows desktop at home and want to use Apple laptop on the go.  What do I have to do to be able to use both platforms when my account is for Win.?  I am thinking of converting my home computer to Apple as well in the near future.  Thanks
    Message was edited by: m48more

    m48more wrote:
    What do I have to do to be able to use both platforms when my account is for Win.?
    Cloud accounts are multi-platform.
    You have a maximum of two activations but can use them on Win/Win or Mac/Mac or Win/Mac. The choice is yours.

  • Has anyone found a solution for the error "The iCloud Control Panel did not install properly".  I'm using windows 7 prof 64 and outlook 2010 and cant get to cloud to winkd ot my mail, contacts, calendar.

    Has anyone found a solution for the error "The iCloud Control Panel did not install properly".  I'm using windows 7 prof 64 and outlook 2010 and cant get to cloud to winkd ot my mail, contacts, calendar.  Cloud control panel version 2.0.

    Has anyone found a solution for the error "The iCloud Control Panel did not install properly".  I'm using windows 7 prof 64 and outlook 2010 and cant get to cloud to winkd ot my mail, contacts, calendar.  Cloud control panel version 2.0.

  • How to list total number of message in specific Topic/queue using wlst comm

    Hi All,
    Message queue
    How to list total number of message in specific Topic/queue using wlst command

    aaaah sorry, I didn't notice you were looking for a SPECIFIC topic, bad me
    then do something like
    <pre>
    connect('weblogic','weblogic','t3://localhost:8001')
    servers = domainRuntimeService.getServerRuntimes();
    if (len(servers) > 0):
    for server in servers:
    jmsRuntime = server.getJMSRuntime();
    jmsServers = jmsRuntime.getJMSServers();
    for jmsServer in jmsServers:
    destinations = jmsServer.getDestinations();
    for destination in destinations:
    if destination.getName() == 'YOURQUEUE':
    print "Destination ", destination.getName(), " MessageCount ", destination.getMessagesCurrentCount()
    </pre>
    of course performance-wise this is a terrible script because you loop on all destinations, I am sure there is a way to lookup a specific destination, but I am too lazy to investigate....

  • Flash stopped working. Updated and enabled to no avail. Am using Windows 7 64-bit and IE10.

    Flash has stopped working. Updated and enabled to no avail. Am using Windows 7 64-bit and IE10.

    Pat Willener wrote:
    What exactly means "stopped working"?
    It had been working on my computer through the different versions of IE for years. I then noticed a few days ago that numerous reliable sites told me to install Flash. I confirmed that it was installed and enabled but all attempts to reinstall resulted in the same condition; Installed under "Programs" ans enabled under "Manage Add-ons". However I still couldn't get it running and Adobe's "Check Now" site showed it NOT installed or enabled. The only thing I can think of that might have had an effect was that I returned to IE10 recently after having some problems with IE11.

  • How To list Total Number Of Message in specific queue

    Hi All,
    Message queue
    How to list total number of message in specific queue using wlst command
    Edited by: 666666 on Mar 8, 2012 4:42 AM

    You might have better luck posting this one on the JMS forum....

  • How to verify my account using my yahoo email? and how to open my apple id in what mail in iphone 4?

    how to verify my account using my yahoo email? and how to open my apple id in what mail in iphone 4?

    Hi stanlaw,
    Welcome to the Support Communities!
    The information below should help you with this.
    Associating and verifying email addresses with your Apple ID
    http://support.apple.com/kb/HE68
    How to verify the primary email address for your Apple ID
    When you first create an Apple ID (using your email address) a verification email will be sent to that address. If you sign in to your Apple ID from the link in that email, the email address will be verified as the primary email address for your Apple ID. You can also resend the email verification if the email address is not verified:
    1. Sign in to My Apple ID to manage your account information.
    2. Click Resend under Primary Email Address.
    3. Verify your changes by following the link in the email you will receive from Apple and signing back in to your account.
    I hope this information helps ....
    Happy Holidays!
    - Judy

  • Hi, I want to use my number for iMessage on my iPhone only and on my macbook pro use my apple id/email and not my number. Also how do i stop the iMessages on my mac appearing on my phone.

    Hi, I want to use my number for iMessage on my iPhone only and on my macbook pro use my apple id/email and not my number, how do i do that? before i updated my phone thats what it was like but now that ive updated i dont know how to change it. Also how do i stop the iMessages on my mac appearing on my phone. can you please help. Thanks

    I tried that but on my iphone i can only click on my email and my number is checked but its in grey doesnt allow me click on it and on my Mac, its the opposite, my email is checked but in grey so doesnt allow me to click on it. im realy confused

  • Numbering Group G1 can be used only for one CoCd and cash journal number

    Hello,
    I was trying to create a cash journal when I got the error message:
    "Numbering Group G1 can be used only for one CoCd and cash journal number".
    Does anyone have an idea what could be wrong?
    Thank you,
    Bola

    Hi,
    Please check whether more than one number range is maintained in  transaction code FBCJC1. If yes, please keep only one as Cash Journal has only one number range. This is the internal number range for Cash Journal.
    If you want different number range for accounting documents then create new document types and assign number ranges to it.
    Regards,
    Tejas

Maybe you are looking for

  • Ability to display data in Different Page Sizes in a Single RTF

    We have a requirement to show different page sizes in a Single RTF file . Please let me know you have worked on such a functionality as part of earlier assignments. Requirement Detail: We have 2 templates (One Legal (8.5*14) and One Statement ( 5.5*8

  • HTTPClient in Oracle 8.1.6

    I am using Oracle 8.1.6 and when I am using https protocol it is giving the error message "unknown protocol https". Regarding this i saw all the protocol handler but I could not find HTTPClient handler . I want to know that whether 8.1.6 support HTTP

  • Selection screen validation  - one field based on another field

    Hi all, i'm getting Month in Select option and Year in Parameter. When i execute the report, it should check whether one is entered without the other one. If so, it should throw error message.  How to do this in selection screen ? this is what the co

  • Modify BCC Flex editor

    Hello, I'd like to know if there's any possibility of using a text area as the Big String editor in the flex part of BCC, or if it is possible to create a new type (data-type) in which the editor is only a text area. The way it is today, the default

  • Java.lang.IndexOutOfBoundsException while using lexicals

    Hi, I am trying to use a dynamic where clause with the described mechanism. - all report parameters defined as global variables in default package - whereclause defined as global variable in default package - defaultPackage defined in DataTemplate -