Le Café Central de

                 ... Deva blogs!!

  • Le Café Central de DeVa

    Exchange Server 2007, 2010: How to query user mailboxes, its permissions using Exchange PowerShell?


    In Exchange Server 2007/2010, you can use Exchange PowerShell cmdlets (especially using Get-Mailbox, Get-MailboxPermission, Get-ADPermission, Get-MailboxFolderPermission) to get a verity of info. I played with couple of the below in different scenarios and want to share the same with you – so that you can give a shot and make use of.

    Scenario # 1: How to query permissions on a mailbox (testuser1)?
    > Get-MailboxPermission test1


    Scenario #2: How to query permissions of all the mailboxes on a particular server?
    > Get-Mailbox –Server “ServerName” | Get-MailboxPermission


    Scenario #3: How to query permissions of all the mailboxes?
    > Get-Mailbox | Get-MailboxPermission
    Note: This will get the list of all permissions (including SELF permissions and inherited permissions)


    Scenario # 4: How to query permissions of all the mailboxes (filter out SELF and inherited permissions)?
    > Get-Mailbox | Get-MailboxPermission | where {$_.user.tostring() -ne "NT AUTHORITY\SELF" -and $_.IsInherited -eq $false}

    Scenario #5: How to query mailbox permissions and Security permissions (only enumerate permissions that are not Inherited)?
    > Get-Mailbox | Get-MailboxPermission | where {$_.IsInherited -eq $False}
    Note: The above query will get you the “explicitly assigned permissions”

    Scenario #6: How to query the explicitly assigned permissions (filter out SELF permissions)?
    > Get-Mailbox | Get-MailboxPermission | where { ($_.IsInherited -eq $false) -and -not ($_.User -like “NT AUTHORITY\SELF”) }

    Scenario #7: How to query list of all mailboxes with Send-As permission assigned on them?
    > Get-Mailbox | Get-ADPermission | where {($_.ExtendedRights -like “*Send-As*”)} | FT –Wrap
    Note: This will get the list of mailboxes with Send-As permission assigned. Also you can notice that it shows Send-As permissions assigned to SELF on all mailboxes also.

    Scenario #8: How to query list of all mailboxes with Send-As permission assigned on them (filter out SELF and inherited permissions as similar to Scenario #4)?
    > Get-Mailbox | Get-ADPermission | where {($_.ExtendedRights -like “*Send-As*”) -and ($_.IsInherited -eq $false) -and -not ($_.User -like “NT AUTHORITY\SELF”)} | FT –Wrap

    Scenario #9: How to query the permissions of shared calendar in Exchange 2010?
    > Get-MailboxFolderPermission –identity “mailboxaccount*:\Calendar”
    Note: If you just try Get-MailboxFolderPermission with identity with mailboxaccount won’t get you the above.

    Scenario #10: How to query the users rights to a specific users mailbox?
    > Get-MailboxPermission –identity “username” | fl user, accessrights


    Scenario #11: How to query the permissions for every users mailbox?
    > Get-MailboxPermission –identity * | fl user, identity, accessrights



    + Exporting the data:
    At anypoint of time, if you want to export the above results to a CSV file, then you can use “Export-csv”. Say, let we try with one of the above scenario – try with scenario # 2:
    > Get-Mailbox | Get-MailboxPermission | Export-csv C:\permissions.csv


    + Automation using .Net Framework:
    If you want to like to add Exchange management capabilities to your Microsoft .NET Framework–based applications then you can try the above by referring the following: http://msdn.microsoft.com/en-us/library/bb332449(v=exchg.80).aspx and http://msdn.microsoft.com/en-us/library/ff326159(v=exchg.140).aspx.

    Happy PowerShelling and automation…!!

  • Le Café Central de DeVa

    PowerShell: Determine Version number, build number and Service Pack of Exchange Server


    In my earlier article, we learnt how to get the Exchange Server version, version/build number of Exchange 2003 and it’s earlier. In this, we will see how to get these info & couple of additional info in Exchange Server 2007/2010 using Exchange Management Shell and Exchange Management Console.

    Using Exchange Management Console:

    To view the server properties in the Exchange Management console, try the following steps:

    1.Start the Microsoft Exchange Management console. In the navigation pane, expand the Server Configuration objects until you locate the server object, and then select the server object.
    2.On the right side, notice the Exchange version number.

    Using Exchange Management Shell:

    For this, I used Get-ExchangeServer cmdlet to view the server properties in Exchange Management Shell:


    I want to save the above info in a .txt file (saved under c:\output.txt):


    Now, I want to customize the above one by the following to get more clarity:


    Still I want to add more info like Site, Server Role and Edition etc..


    Hope this helps you to move ahead.

  • Le Café Central de DeVa

    Outlook Object Model: How to include usemap attribute programmatically?


    In this post, I will show you how to make use of usemap attribute of img HTML element in HTML emails programmatically. For this, I used Outlook 2010 VBA & Outlook Object Model. You can design the application with C# or VB.Net with Outlook Object Model library as per your wish.

    We will do this exercise in two steps:

    First, we need to set the Bodyformat of the message as olFormatHTML
    Second, at the Message body we need to include the usemap attribute with img HTML element.

    Here is the code snippet that I tried:

       1: ...
       2: Dim str As String
       3: Dim newMSG As Outlook.MailItem
       5: Set newMSG = Application.CreateItem(0)
       6: newMSG.To = Session.CreateRecipient("test@testexchange.com")
       7: newMSG.Subject = "Test message"
       8: newMSG.BodyFormat = olFormatHTML
       9: newMSG.Body = "start Body here.  "
      10: newMSG.Body = newMSG.Body & "  Add more text."
      12: str = "<html> <body> <p>Click the logo:</p>"
      13: str = str & " <img src='http://www.microsoft.com/presspass/imagegallery/images/products/office/office2010/MS_Office_w_2010_vertical_web.jpg' width=200 height=200 alt='Sites' usemap='#sitesmap' />"
      14: str = str & " <map name='sitesmap'> <area shape='rect' coords='0,0,82,126' alt='Bing' href='http://www.bing.com'/>"
      15: str = str & " <area shape='circle' coords='0,90,58,3' href='www.microsoft.com' alt='Microsoft'/>"
      16: str = str & "</map> </body> </html>"
      18: newMSG.HTMLBody = str
      19: newMSG.Save
      20: 'newMSG.Send
      21: newMSG.Display
      22: ...

    Once you’re done, try run the above sample – you’ll see the below results whenever you move to cursor to the above co-ordinates.



    Happy programming!!

  • Le Café Central de DeVa

    Debug : Workaround - Remote debugging monitor (msvsmon.exe) error on Windows 7


    I was playing around debugging a custom app in one of my Windows 7 & Visual Studio 2010. When I tried running msvsmon.exe (Remote Debugging Monitor) and got the following error message when attempting to remote debug:

    Error while trying to run project: Unable to start debugging.

    This operation returned because the timeout period expired.

    During further investigation, I found that the issue is that the firewall is not setup properly on the Win7 machine for remote debugging. I noticed that when msvsmon first launches, it will prompt the user to configure the firewall.

    Per the debugger blogpost, this happens due to the firewall security API changes since Vista, the prompt may not come up. I tried the following workaround to move ahead:

    Control Panel->System and Security->Windows Firewall: Change notification settings -> enable Notify me when Windows Firewall blocks a new program ->Ok

    After implementing the above, I started remote debugging again and this time I can notice that msvsmon shows popup a windows security alert dialog box that prompt to grant access permission to msvsmon.

    Happy debugging!!

  • Le Café Central de DeVa

    Handy: Keyboard Shortcuts for Windows 8


    Have you started playing around with new Windows 8 OS? You can get the list of Keyboard shortcuts for Windows 8….Enjoy!!

  • Le Café Central de DeVa

    Outlook Object Model: How to assign a Webpage to a specific Outlook folder programmatically?


    In this post we will see how to assign a web page to a specific Outlook folder programmatically using C# and Outlook Object Model. For this I tried the following sample, which checks for a folder named “HtmlView” in Microsoft Office Outlook. If the folder does not exist, the code creates the folder and assigns a Web page to it. If the folder exists, the code displays the folder contents.

    The following sample is written using C#.Net, Visual Studio 2010 and Outlook 2010 (Outlook Object Model API).

    Code snippet:

       1: //Microsoft.Office.Interop.Outlook._Application
       2: // Create an Outlook application.
       3: Outlook._Application oApp = new Outlook.Application();
       5: // Get the MAPI NameSpace and Logon values.
       6: Outlook._NameSpace oNS = (Outlook._NameSpace)oApp.GetNamespace("MAPI");
       7: oNS.Logon(Missing.Value, Missing.Value, true, true);
       9: //Assign a Web page with a specific Outlook folder
      10: Outlook.MAPIFolder newView = null;
      11: string viewName = "HtmlView";
      12: Outlook.MAPIFolder inBox = (Outlook.MAPIFolder) oApp.ActiveExplorer().Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
      13: Outlook.Folders searchFolders = (Outlook.Folders)inBox.Folders;
      14: bool foundView = false;
      16: foreach (Outlook.MAPIFolder searchFolder in searchFolders)
      17: {
      18:    if (searchFolder.Name == viewName)
      19:       {
      20:          newView = inBox.Folders[viewName];
      21:          foundView = true;
      22:       }
      23: }
      25: if (!foundView)
      26: {
      27:      newView = (Outlook.MAPIFolder)inBox.Folders. Add("HtmlView", Outlook.OlDefaultFolders.olFolderInbox);
      28:      newView.WebViewURL = "http://www.microsoft.com";
      29:      newView.WebViewOn = true;
      30: }
      32: oApp.ActiveExplorer().SelectFolder(newView);
      33: oApp.ActiveExplorer().CurrentFolder.Display();

    Run the sample and you will see the following output in Outlook:

    Outlook 2010 - Output

    Happy programming!!

  • Le Café Central de DeVa

    Admin: How to remove retention policy from Outlook/Exchange?


    ·To remove retention policy from Outlook:

    When you remove a retention policy from an email message, the folder policy applies to the item, if one is assigned.

    1. In the message list, click a message. (To select more than one message, press and hold CTRL as you click each message.)

    2. On the Home tab, in the Tags group, click Assign Policy.


    3. Under Retention Policy, click Use Folder Policy.

    Note: The retention policy for a message appears in the header in the Reading Pane under the recipient names and includes the expiration date. If no retention policy is applied, no information appears under the message recipient names.

    From Exchange:

    You can use the following exchange cmdlet: http://technet.microsoft.com/en-us/library/dd297962.aspx. Please note that the retention policies are used to apply message retention settings to folders and items in a mailbox.

    The below cmdlet removes an existing retention policy "Business Critical", which is assigned to users, and suppresses the confirmation prompt.

    > Remove-RetentionPolicy -Identity "Business Critical" -Confirm:$false -Force

Page 1 of 1 (7 items)