I need to run exchange cmdlets from ac# 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?
您是否尝试过http://msdn.microsoft.com/zh-cn/library/ff326155(v=EXCHG.140).aspx中的Exchange命令行管理程序SDK中的示例?
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
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.