Exchange Server 2007 : Getting Mailbox statistics using C#.Net & Exchange Powershell
In this session, we will have a look about how to get the mailbox statistics information using from Exchange Server 2007 SP1 using C#.Net & Exchange Powershell.
I tried the following code to get the mailbox statistics…
1: ....
2: //Create Runspaceconfiguraiton object
3: RunspaceConfiguration config = RunspaceConfiguration.Create();
4: PSSnapInException snapEx = null;
5:
6: //Add it to the Powershell SnapIn
7: PSSnapInInfo info = config.AddPSSnapIn("Microsoft.Exchange.Management.PowerShell.Admin", out snapEx);
8:
9: //Create a Runspace
10: Runspace space = RunspaceFactory.CreateRunspace(config);
11:
12: //Supply the Command & its relevant parameters collection
13: Command createcmd = new Command(@"Get-Mailboxstatistics testmailbox");
14: createcmd.Parameters.Add("server", "servername");
15:
16: //Create the collection & invoke the pipe
17: pipe.Commands.Add(createcmd);
18: Collection<PSObject> results = null;
19: results = pipe.Invoke();
20: ....