Reputation: 11
I need to run exchange cmdlets from a c# console application.
I followed the guide from http://msdn.microsoft.com/en-us/library/bb332449.aspx for a simple command with a single parameter
The cmdlets I need to run is:
Get-MailboxStatistics -server evs | Select servername, StorageGroupName,databasename,@{expression={$_.TotalItemSize.value.ToKB()}},ItemCount,mailboxguid
I cannot specify the field that I need after the select
command and I don't know how I can pass the expression @{expression={$_.TotalItemSize.value.ToKB()}}
to cmdlets.
Is there a way to do it in managed code?
Upvotes: 1
Views: 905
Reputation: 669
You can use Import-PSSession to move the remote session into a local powershell runspace.
Here are 2 methods.
Powershell to Exchange 2013 - Restricted language mode error http://blogs.msdn.com/b/akashb/archive/2010/03/26/how-to-call-ps1-script-from-managed-code-using-remote-powershell-exchange-2010.aspx
Upvotes: 0
Reputation: 26
Have you tried the examples in the Exchange Management Shell SDK at http://msdn.microsoft.com/en-us/library/ff326155(v=EXCHG.140).aspx?
Upvotes: 1
Reputation: 17018
Take a look at the Redemption library: http://www.dimastr.com/redemption/
I'm not sure if it satisfies your specific requirements but it does expose a lot of information through managed code.
Upvotes: 0