Le Café Central de
Deva             


                    ... Deva blogs!!



  • Le Café Central de DeVa

    Get all mailbox information from WMI & C#.Net

    • 0 Comments

    In one scenario, there was a need for me to get all mailbox related information using WMI and C#.Net.

    Here is a code snippet to get all mailbox information from an Exchange Server - WMI & C#.Net.

    using System;
    using System.Management;

    namespace ConsoleTwo
    {
        class Class1
        {


            [STAThread]
            static void Main(string[] args)
            {
                try
                {
     
                    System.Management.ConnectionOptions objcon = new System.Management.ConnectionOptions();
                     objcon.Impersonation = ImpersonationLevel.Impersonate;
     
                    // Exchange Server Name
                    string cServername = "Server Name";
     
                    // Create a management scope into Exchange WMI namespace
                    System.Management.ManagementScope exScope =
                        new System.Management.ManagementScope(@"\\" + cServername + @"\root\MicrosoftExchangeV2", objcon);

                    // Create a query to get the data from the Exchange WMI
                    System.Management.ObjectQuery objQry =
                        new System.Management.ObjectQuery("SELECT * FROM Exchange_Mailbox");

                    // Retrieves a collection of management objects based on the query.
                    System.Management.ManagementObjectSearcher objSrch =
                        new System.Management.ManagementObjectSearcher(exScope, objQry);
                    System.Management.ManagementObjectCollection qryCol = objSrch.Get();

                     // Loop each item in the collection
                    foreach (System.Management.ManagementObject mailBox in qryCol)
                    {
                         Console.WriteLine("{0} {1} {2}", mailBox["MailboxDisplayName"].ToString() , mailBox["TotalItems"].ToString() , mailBox["size"].ToString() );
                     }
                 }
                catch (Exception eVal)
                {
                    Console.Write(eVal.InnerException + eVal.Message + eVal.Source + eVal.StackTrace );
                }
                Console.Read(); 
            }
        }
        }

  • Le Café Central de DeVa

    Exchange Server 2007 - Transport Agent

    • 0 Comments

    Transport Agent - Introduction

    Exchange Server 2007 provides a class library based on the MS.NET Framework that enables you to implement transport agents that programmatically check and take action on transport events. It can be used to change and read the message contents during these events.

    Transport agents enable you to access information about messages that travel through the Edge and Hub Transport servers. They have access to e-mail messages and their contents while the messages move through the transport services.

    Pre-requisites

    • An Exchange Server 2007 has Edge and Hub Transport server roles installed
    • Microsoft.Net 2.0 SDK installed
    • Microsoft Visual Studio .Net 2005 (recommended)

    Used Namespaces 

    • Microsoft.Exchange.Data.Transport            
    • Microsoft.Exchange.Data.Transport.Email    - to make use of common email elements
    • Microsoft.Exchange.Data.Transport.Smtp     - to make use of SMTP receive agent
    • Microsoft.Exchange.Data.Transport.Routing  - to make use of Routing agent

    Referencing Assemblies 

    • When we install Exchange Server 2007 in our system, Exchange Sever installer installs & registers in the global assembly cache (GAC) the assemblies that are required for the development of transport agents.
    • To begin implementing a transport agent, create a reference to the Microsoft.Exchange.Data.Transport assembly in a class library project

    Samples

    Installing an Agent

    Once you compile the agent to a .dll; you must install and enable the agent on development Exchange server. At Exchange Management Shell(EMS), use the Install-TransportAgent command to install your agent, and the Enable-TransportAgent command to enable your agent.

    For example you can make use of EMS to install and enable an agent named "MyAgeOne" by using a class derived from SmtpReceiveAgentFactory named MyAgentOne.MyAgeOneFactory.

    Install-TransportAgent -Name "MyCustomAgent" -TransportAgentFactory "MyAgeOne.MyAgeOneFactory" -AssemblyPath "C:\myagents\MyAgeOne.dll"

    Enabling an Agent

    For example the agent MyCustomAgent on the server on which the agent is installed:

    Enable-TransportAgent -Name "MyCustomAgent"

  • Le Café Central de DeVa

    Send Email using CDO without installing the SMTP Service

    • 0 Comments

    Here is a code snippet script that uses CDO to send email from a computer.


    Set objEml = CreateObject("CDO.Message")
    objEml.From = "testuser@admin.com"
    objEml.To = "sampleuser@admin.com"
    objEml.Subject = "Test Mail"
    objEml.Textbody = "Oops...You got the Mail!!"
    objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
    objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtpserver"
    objEml.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
    objEml.Configuration.Fields.Update
    objEml.Send
    Msgbox "Mail Sent!"


    Please note that,
    1) Replace the name SSN with SMTP server name
    2) The script will work where the SMTP Service has not been installed

  • Le Café Central de DeVa

    Create Application Pool using WMI

    • 1 Comments

    Here is an code snippet that creates application pool [here for example MSSharePointAppPool application pool] using WMI Script.

    strComputer = "."
    Set objWMIService = GetObject("winmgmts:{authenticationLevel=pktPrivacy}\\" & strComputer & "\root\microsoftiisv2")
    Set colItems = objWMIService.ExecQuery("Select * From IIsApplicationPool Where Name = " & "'W3SVC/AppPools/MSSharePointAppPool'")

    For Each objItem in colItems
    objItem.Start
    Next

    Supported Platform: Windows Server 2003

  • Le Café Central de DeVa

    Powershell & cmdlet - In a Nutshell - Part 1 - Introduction

    • 2 Comments

    What is a PowerShell?

    Windows PowerShell or Powershell or Windows Shell is a new Windows command-line shell (includes an prompt and scripting environment, which can accept and return text) designed for specially system adminis. 

    Windows Powershell Vs. Classic Shell(s):

    • Windows PowerShell does not process text. Instead, it processes objects based on the .NET platform.
    • Windows PowerShell comes with a large set of built-in commands with a consistent interface.
    • All shell commands use the same command parser, instead of different parsers for each tool. This makes it much easier to learn how to use each command.

    New feature?

    PowerShell uses its own scripting language, rather than reusing existing languages, for the following reasons.

    • Windows PowerShell needed a language for managing.NET objects.
    • The language needed to provide a consistent environment for using cmdlets.
    • The language needed to support complex tasks, without making simple tasks more complex.
    • The language needed to be consistent with higher-level languages used in .NET programming, such as C#.

    Advantages:

    It is built on top of the .NET common language runtime (CLR) and the .NET Framework, and accepts and returns .NET objects.

    • This fundamental change in the environment brings entirely new tools and methods to the management and configuration of Windows.
    • It gives you access to the file system on the computer easily.
    • So Windows PowerShell providers enable you to access other data stores, like the registry & digital signature certificate stores.
    • Windows PowerShell introduces cmdlet, a single-function command-line tool built into the shell.
      • We can use each cmdlet separately
      • But cmdlet power can be realized when you use these simple tools in combination to perform complex tasks.
      • It have more than 100 basic core cmdlets, and you can write your own cmdlets and share them with other users.

    Pipeline operator:

    The Pipeline operator helps to pass the output of one command to another command as input. In Powershell-cmdlet it receives an object can act directly on its properties and methods without any conversion or manipulation. So that users can refer to properties and methods of the object by name, rather than calculating the position of the data in the output.

    • The pipeline operator (|) sends the result of the command on its left to the command on its right.

    What can we work with Powershell?

    • Can run Windows command-line programs
    • Can open GUI programs like Notepad, Calculator
    • Can capture the text that the Windows programs generate and also make use of that values in Powershell

    For example,

    "c:\> ipconfig | select-string  -pattern 255"

    where,
    - "ipconfig" command-line program, which will provide Windows IP configuration details
    - "select-string -pattern 255" cmdlet to manipulate to find the text pattern "255" in the Ipconfig output

  • Le Café Central de DeVa

    How to programmatically create a global address list (GAL) in Exchange Server

    • 2 Comments

    I found an interesting article which talks about Microsoft Visual Basic sample code that demonstrates how to programmatically create a global address list (GAL) in Exchange Server.

    Please click here to read the article

  • Le Café Central de DeVa

    EWS : Delegate Access using Exchange Web Services

    • 0 Comments

    Delegate Access

    Exchange 2007 enables delegates to access the mailbox of a principal and perform create/delete/update/copy/search operations using Exchange Web Services (EWS).

    There are two ways we can access the contents of other users mailboxes:

    • Exchange Impersonation - Enable one account to act as another account
    • Delegate Access - Account act on behalf of the account of principal

    EWS is a powerful tool for accessing other users mailboxes. Delegate access provides a convenient way for EWS clients to act on behalf of other user accounts and opens the way to create client applications that can work across mailboxes.

    For more information, please click here

  • Le Café Central de DeVa

    Powershell & cmdlet - In a Nutshell - Part 2 - About Cmdlets

    • 1 Comments

    About cmdlets: 

    After entry of Exchange Server 2007, there is a famous buzzword called "cmdlet" started revolving. In this series, we'll look some of its features, usage and importance in Exchange Server 2007 environment.

    What is a cmdlet?

    A cmdlet, pronounced "command-let", is the basic unit of Microsoft Shell (codenamed Monad). The Microsoft Shell (Monad) is a break through console shell for Windows. It's designed for the manipulation of objects. 

    They resemble built-in commands in other shells, for example, the Dir command in cmd.exe.

    Advantages of cmdlet with other Existing shells:

    • cmdlets can be called directly from the command line in Exchange Management Shell and run under the context of shell (not as separate process)
    • Unlike in other shells, in the Exchange Management Shell, cmdlets have descriptive verb-noun names.
    • In Unix and Linux environments, shells pipe text from one application to another
    • Monad allows the piping of .NET objects in Windows Environment using console shell.
    • In traditional shells, the commands are executable programs that may vary from very simple to very complex.
    • For Example, in Windows Powershell, we have a new feature "single-feature command - cmdlet" that manipulates objects in available in Windows PowerShell. 
    • Most of the cmdlets are simple and designed to be used in combination with other cmdlets.

    Adjoining issues:

    Monad is revolutionary because text strings were a limitation. Lets we understand how it works.

    • Normally in any console shell, data had to be represented in text & it needs to be broken up into units so that other programs could understand.
    • In Unix or Linux environments to achieve the functionality we need to on depend program like grep to do that.

     

  • Le Café Central de DeVa

    Powershell & cmdlet - In a Nutshell - Part 4 - Verify Autodiscover Service info for Outlook 2007 using "Test-OutlookWebServices" cmdlet

    • 5 Comments

    How to verify Autodiscover Service info for Outlook 2007 using "Test-OutlookWebServices" cmdlet:

    In Exchange Server 2007 environment, to verify the Autodiscover service settings for Outlook and that has Client Access server role installed or not, we can use of "Test-OutlookWebServices cmdlet". It verifies information for the services like, (1) Availability service (2) Outlook Anywhere (3) Offline Address Book (4) Unified Messaging.

    The cmdlet tests for a connection to each service. For example, it requests the availability service for the above user to check the user's free/busy information obtained from Client Access server to the Outlook 2007.

    For Example,  "test-OutlookWebServices -identity:sample@administrator.com"

    This cmdlet verifies the service information that is returned to the Outlook 2007 client from the Autodiscover service for sample@administrator.com

  • Le Café Central de DeVa

    Send Email from a Script using CDO

    • 2 Comments

    Here is a code snippet of a script that uses CDO to send email from a computer. 

     Set objEml = CreateObject("CDO.Message")
     objEml.From = "testuser@admin.com"
     objEml.To = "sampleuser@admin.com"
     objEml.Subject = "Sample Message"
     objEml.Textbody = "Test Message from Test User"
     objEml.Send
     Msgbox "Mail Sent!!"

    Please note that the script will work only where SMTP Service has been installed.

  • Le Café Central de DeVa

    Powershell & cmdlet - In a Nutshell - Part 5 - Listing Service Information using Windows Powershell & cmdlet

    • 1 Comments

    How to list Service Information using Windows Powershell & cmdlet: 

    In Exchange Server 2007, Get-Service cmdlet will be used to retrieve information about the services installed on the computer. By default, it will return the results in alphabetical order.

    (1) Get information about the services installed 

    Get-Service

    It will list/get you the information about the service name, status and, display name.

    (2) Get information about the services in sorted

    Get-Service | Sort-Object status, displayname

    Here,
    Sort-Object - the cmdlet can sort the data in any way we want, Status - service property which needs to be filtered, display - represents display name

    (3) Get information about the services installed, but only for running services

    Get-Service | Where-Object {$_.status –eq "running"}

    Here, Where-Object - the cmdlet filters out everything except those services that are stopped, $_. - the object passed across the pipeline, Status - service property which needs to be filtered, -eq "running" - represents the running services

    (4) Get information about the services installed, but only for stopped services

    Get-Service | Where-Object {$_.status –eq "stopped"}

    Here, Where-Object - the cmdlet filters out everything except those services that are stopped, $_. - the object passed across the pipeline, Status - service property which needs to be filtered, -eq " stopped" - represents the stopped services

  • Le Café Central de DeVa

    Exchange .Net Framework Extensions

    • 1 Comments

    Exchange .NET Framework Extensions provide useful classes and data structures that enable you to access and manipulate the various parts of e-mail messages.

    Available Namespaces:

    • Microsoft.Exchange.Data.Mime
      Enables stream-based and DOM-based access to Multipurpose Internet Mail Extensions (MIME) data, including the ability to filter MIME content.
    • Microsoft.Exchange.Data.TextConverters   
      Provides classes and data structures that enable custom filtering of e-mail body content and conversion between several different formats, including HTML, RTF, and plain text.
    • Microsoft.Exchange.Data.iCalendar and Microsoft.Exchange.Data.Tnef   
      Provide classes and data structures that let you read and write calendar items for appointments, meetings, and events.
    • Microsoft.Exchange.Data.Encoders   
      Provides classes and data structures that let you easily convert the encoding of an e-mail message.
  • Le Café Central de DeVa

    Monitoring Event Sink # 1 - Listing registered Event sink information

    • 0 Comments

    Use the following command at command window to get list of registered Event sink registration:

    Cscript [//NOLOGO] ListMailboxes.vbs {/F:filename | /S:servername} [/DEBUG]

    Where,

    //NOLOGO

    Suppresses the version of Windows Script Host (WSH) and copyright information.

    /F

    The name of the text file that contains the names of the servers, will be available one per line, for which you want to list mailboxes. You must create the text file before you use this script.

    /S

    Name of the server that contains the mailboxes that you want to list.

    /DEBUG

    Outputs verbose debug information that you can use for diagnosis.

    Note:

    You must specify either the /F or /S switch.

    For more information, please read this Technet article click here.

  • Le Café Central de DeVa

    Exchange Server 2007 - Do you know?

    • 4 Comments

    Do you Know?

    Several features that are found in earlier versions of Microsoft Exchange Server have been removed (Discontinued features and De-emphasized functionality) from Exchange 2007.

    Some of the de-emphasized legacy technologies are,

    • Public folders - Free/busy calendaring functionality is provided by the Availability service.
    • Proxy address generators - Use the Exchange Management Shell.
    • CDO 1.2.1 - This functionality is provided by the Exchange Web Services.
    • MAPI32 - This functionality is provided by the Exchange Web Services.
    • CDOEX (CDO 3.0) - This functionality is provided by the Exchange Web Services.
    • Exchange WebDAV extensions - This functionality is provided by the Exchange Web Services.
    • ExOLEDB - This functionality is provided by the Exchange Web Services.
    • Store events - This functionality is provided by the Notification Web service.
    • Streaming backup APIs.
    • Exchange 2003 Virus Scanning Application Programming Interface (VSAPI).

     There is a fine Microsoft Technet article which give detailed information into it. Click here to find more 

  • Le Café Central de DeVa

    EWS : Best Practices for Using Exchange Web Services for Calendaring Tasks

    • 2 Comments

    Best practices for using Exchange Web Services for Calendaring Tasks 

    In Exchange Server 2007 - Exchange Web Services (EWS) provides,

    • Rich set of Web methods and types
    • can use to create/update/generate calendar work flow between Exchange 2007 mailboxes.

    These methods can also cause a lot of confusion and unforeseen consequences when they are used incorrectly.

    Here is an interesting article, which talks about the "Best practices for using Exchange Web Services for Calendaring Tasks"

  • Le Café Central de DeVa

    Powershell & cmdlet - In a Nutshell - Part 3 - Identifying Cmdlet

    • 1 Comments

    Identifying Cmdlet:

    Simple way to recognize the cmdlets by their name format -- "a verb and noun separated by a dash (-), such as Get-Help, Get-Process, and Start-Service"

     
    For example, each cmdlet has a help file that you can access by typing:

    get-help <cmdlet-name> -detailed

    It will provide detailed view of the cmdlet help file includes a description of the cmdlet, the command syntax, descriptions of the parameters, and example that demonstrate use of the cmdlet.

    Still for more information, we can identify that,

    • the "get" cmdlets only retrieve data
    • the "set" cmdlets only establish or change data
    • the "format" cmdlets only format data
    • the "out" cmdlets only direct the output to a specified destination.
  • Le Café Central de DeVa

    Verify the status of an Web Directory Application using WMI

    • 1 Comments
    Here is a code snippet which is used to verify the status of an Web Directory Application using WMI, without opening IIS Manager. 


    strComputer = "."
    Set objWMIService = GetObject("winmgmts:{authenticationLevel=pktPrivacy}\\" & strComputer & "\root\microsoftiisv2")
    Set colItems = objWMIService.ExecQuery("Select * From IIsWebDirectory Where Name = " & "'W3SVC/2142295254/root/aspnet_client_folder'")

    For Each objItem in colItems
    strStatus = objItem.AppGetStatus
    If strStatus = 2 Then
    Wscript.Echo "The application is running."
    ElseIf strStatus = 3 Then
    Wscript.Echo "The application is stopped."
    Else
    Wscript.Echo "The status could not be determined."
    End If
    Next

    Supported Platform: Windows Server 2003
  • Le Café Central de DeVa

    Microsoft Surface - Provides life in Restaurants, Hotels, Retail Locations and Casino Resorts

    • 4 Comments

    Microsoft Launches New Product Category: Surface Computing Comes to Life in Restaurants, Hotels, Retail Locations and Casino Resorts

    First commercially available surface computer from Microsoft breaks down barriers and provides effortless interaction with information using touch, natural gestures and physical objects

    Click here to read more about the article

  • Le Café Central de DeVa

    Exchange Web Services

    • 0 Comments

    Exchange Server 2007 introduced a new programming model by using the Web Services. 

    • It is a programmable interface can be used to provide client access to Exchange store data and information management functions.
    • It handles Simple Object Access Protocol (SOAP) messages sent over HTTP.
    • It will improve the efficiency & programmable access to core business data and functions.
    • It provides heterogeneous servers and clients access to the same business-critical data.

    EWS includes the following Web services:

    • Auto discover   Provides configuration information for setting up client applications that connect to mailbox servers.
    • Availability   Provides free/busy data about a user's mailbox. The free/busy data is also used to identify suggested meeting times and provides client Out of Office (OOF) management functionality.
    • Messaging Records Management    Enables the assignment of Managed E-Mail folders to mailbox users.
    • Notification   Notifies the client application of events that are associated with a mailbox. The subscription model can be either push- or pull-based.
    • Synchronization   Provides a one-way synchronized cached copy of a user's folders and items.
    • Exchange Data Service   Provides the following features:
      • Functions to create, update, delete, copy, find, get, and move folders that are associated with a mailbox user, and also the ability to find items that are contained in a folder.
      • Access to the Exchange data store. A client application can create, update, delete, copy, get, move, and send items by using the Exchange Data Service Web service.
      • Ambiguous name resolution.
      • The ability to return the members of distribution list.
      • Access to attachments in the Exchange store.
  • Le Café Central de DeVa

    Monitoring Event Sink # 2 - Required Permissions

    • 0 Comments
    Event Sink Permission
    • The account that is registering the event must be the same account as the mailbox owner, or an account that has full mailbox access on the mailbox where the event is being registered.
    • By default, the Exchange Administrator account does not have mailbox permissions.
    • You must give the administrator full mailbox permissions for the mailbox that you are registering the sink on.
  • Le Café Central de DeVa

    Public Folder

    • 0 Comments

    Public Folders

    They're intended to serve as a repository for information that is shared among many users. Public folders should be used when your business requires data replication to multiple servers. 

    Used for

    • Public folders can be used for shared communication, such as discussions through message posts, shared e-mail messages, contacts, group calendars, archiving of distribution list posts, and support for Network News Transfer Protocol (NNTP).
    • Public folders can be used for shared content management. Like file shares, public folders can be used to store content, such as documentation. Public folders are also good for sharing content if you do not require versioning and provisioning.

    If you require offline storage of information or replicated storage of information, public folders are an ideal repository.

    Not used @

    • Public folders were not designed for archiving data. Users who have mailbox limits sometimes use public folders, instead of personal folder (.pst) files, to archive data. This practice is not a recommended best practice because it increases storage on public folder servers and undermines the goal of mailbox limits.
    • Public folders were not designed for document sharing and collaboration. Public folders do not provide versioning or other document management features, such as controlled check-in and check-out functionality, and automatic notifications of content changes.
  • Le Café Central de DeVa

    Microsoft Surface - Features

    • 0 Comments

    Microsoft Surface - Key Features:

    Direct interaction: Users can actually “grab” digital information with their hands, interacting with content by touch and gesture, without the use of a mouse or keyboard.
     
    Multi-touch: Surface computing recognizes many points of contact simultaneously, not just from one finger like a typical touch-screen, but up to dozens of items at once.
     
    • Multi-user: The horizontal form factor makes it easy for several people to gather around surface computers together, providing a collaborative, face-to-face computing experience.
     
    • Object recognition: Users can place physical objects on the surface to trigger different types of digital responses, including the transfer of digital content. 

  • Le Café Central de DeVa

    Powershell &amp; cmdlet - In a Nutshell - Part 6 - Exchange Management Shell (EMS)

    • 0 Comments

    Exchange Management Shell:

    • It's a new automation and scripting shell.
    • It has the command-line management interface and associated command-line plug-ins for Exchange Server that enable automation of administrative tasks in an Exchange 2007 environment. 
    • It is built on Microsoft Windows PowerShell (“Monad").
    • With Exchange Management Shell administrators can achieve every aspect of Exchange Server 2007.
      • For example, configure transport agents, SMTP connectors, enable new e-mail accounts
    • Mainly the tasks that you can't perform in the Exchange Management Console can be achieve through Exchange Management Shell.
  • Le Café Central de DeVa

    Available Services - Exchange Server 2007

    • 1 Comments

    As we know, Exchange Server 2007 have newly designed and with tons of new features. It also offers various services, likes its earlier versions. All previous versions of Exchange Server included components that were implemented as services.

    When we install Exchange Server 2007, setup runs a set of tasks that install new services. The Exchange Server 2007 setup will install all services whether they are immediately needed or not, some services will only become active when specific features are used.

    I found this interesting article, which tabulates by name and by short name the various services that are installed by Exchange 2007. Also included is a description of each service, the server role that installs the service, and whether the service is required or optional....

    Please click here to read more

     

  • Le Café Central de DeVa

    Mailbox store & Public folder Store - Basic Information

    • 0 Comments

    Basic Information about "Mailbox store and Public folder Store"

    • MS Exchange store is a storage platform. The Exchange store is also known as the Web Storage System.
    • It provides a single repository for managing multiple types of unstructured information in one infrastructure.
    • Mailbox stores & public folder stores are two of the components of the Exchange store.

    MS Exchange Server 2000 & 2003 include two types of information databases:

    • Mailbox Store:
      • Hold personal mailbox information.
    • Public Folder Store:
      • It's a shared repository, where information that is shared among many users. Public folders should be used when your business requires data replication to multiple servers.
Page 1 of 2 (31 items) 12