Using–Filter, Select-Object, ForEach-Object in C# – Exchange PowerShell Automation

Have you ever tried migrating Exchange PowerShell script to be used from C# code?  I needed to convert the following script to C# Get-Mailbox -filter {ResourceType -ne "Room"}| Select-object Alias,DistinguishedName,Identity | foreach-object {Get-MailboxFolderStatistics $_.Alias} If you run the above script in Exchange 2010 Management Shell you might get the following error message: Pipeline not executed…

0

EWS Managed API is lying to me!

I have been working with Exchange Web Services(EWS) for a long time and this is the first time I saw that the EWS was lying to me! The code was executing a FindItem call on a list of folders and all of a sudden it threw the following error: “Error occurred: The request failed. The…

0

HOW TO: Call .PS1 script from Managed code using Remote Powershell(Exchange 2010)

As promised below is the code to call a .PS1 script and pass parameters to it. Most of the code is very similar to my previous post that showed how to call Exchange & PowerShell cmdlet. using System;using System.Collections.Generic;using System.Text;using System.Management.Automation;using System.Management.Automation.Runspaces;using System.Management.Automation.Remoting;using System.Collections.ObjectModel;using System.Security;namespace CallingScriptPS{ class Program { static void Main(string[] args) { string…

0

HOW TO: Migrating Exchange 2007 PowerShell Managed code to work with Exchange 2010

Will my Exchange 2007 PowerShell Managed code work with Exchange 2010 as is? Unfortunately the answer is NO, fortunately there are not many changes that you will have to make. The management experience given by Exchange 2010 through PowerShell has been moved all the way from Local to Remote. Dave Vespa has a detailed post…

3

"Object reference not set to an instance of an object" error when trying to create object of System.Net.Mail.MailMessage

A few days ago I ran into an interesting problem. A customer who was trying to send a mail using System.Net.Mail was getting the error "Object reference not set to an instance of an object" when trying to create a Instance of the MailMessage class. Code that was failing MailMessage message = new MailMessage() The…

0

HOW TO: Read User Configuration for OWA in Exchange 2010 using EWS Managed API 1.0

The User Configuration operations enable clients to create, delete, retrieve, and update user configuration information. These operations are new in Exchange 2010. Configuration data consists of groups of related application settings. Each group of settings is stored together in separate stream properties that are set on FAI messages. The OWA configuration its stored in IPM.Configuration.OWA.UserOptions…

0