Displays the first and 2nd level folders in a MAP profile


posted by Thomas Lee
10-08-2009

Downloads: 335
File size: 1.8kB
Views: 1,431

Embed
Displays the first and 2nd level folders in a MAP profile
  1. <# 
  2. .SYNOPSIS 
  3.     This script displays the MAPI namespace in the current  
  4.     Outlook Profile. 
  5. .DESCRIPTION 
  6.     This script creates and Outlook.application object, 
  7.     then gets and displays the top level folders in the store, and 
  8.     the folders one level below.       
  9. .NOTES 
  10.     File Name  : Get-OutlookFolders.ps1 
  11.     Author     : Thomas Lee - tfl@psp.co.uk 
  12.     Requires   : PowerShell V2 
  13. .LINK 
  14.     This script posted to: 
  15.         http://www.pshscripts.blogspot.com 
  16. .EXAMPLE 
  17.     PSH [C:\foo]: .\Get-OutLookFolders.PS1' 
  18.     3 Top Level Folders: 
  19.        Mailbox - Thomas Lee 
  20.        Public Folders 
  21.        Archive Folders 
  22.  
  23.     Folder 'Mailbox - Thomas Lee' contains the following subfolders: 
  24.        Deleted Items 
  25.        Grateful Dead 
  26.        Inbox 
  27.        Outbox 
  28.        Sent Items 
  29.        Calendar 
  30.        Contacts 
  31.        Drafts 
  32.        Journal 
  33.        Junk E-mail 
  34.        Notes 
  35.        Quarantine 
  36.        RSS Feeds 
  37.        Sync Issues 
  38.        Tasks 
  39.        Conversation Action Settings 
  40.        Quick Step Settings 
  41.        Suggested Contacts 
  42.     Folder 'Public Folders' contains the following subfolders: 
  43.        Favorites 
  44.        All Public Folders 
  45.     Folder 'Archive Folders' contains the following subfolders: 
  46.        Deleted Items 
  47.        Sent Items 
  48.        Calendar 
  49.        Journal 
  50.        Tasks 
  51. #> 
  52.  
  53. ##  
  54. # Start of Script 
  55. ## 
  56.  
  57. # First create Outlook object and get the Mapi namespace. 
  58. $Outlook = New-Object -com Outlook.Application 
  59. $Namespace = $outlook.GetNamespace("MAPI") 
  60.  
  61. # Now display top level folders 
  62. "{0} Top Level Folders:      " -f $Namespace.folders.count 
  63. foreach ($Fl in $namespace.Folders) { 
  64.   "   {0}" -f $Fl.Name} 
  65. "" 
  66. # Now look inside 
  67. foreach ($Folder in $Namespace.Folders) { 
  68. "Folder `'{0}`' contains the following subfolders: " -f $Folder.Name 
  69.   foreach ($fl in $Folder.Folders){ 
  70.   "   {0}" -f $Fl.Name 
  71.   
  72. }  
  73. # end of script 
Filed under: , , ,
This script uses outlook's scripting engine to open up your profile and work out the top and 2nd level of folders in your profile.
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.