Exchange 2010サーバのすべてのデータベースをメールボックスにリストアップする必要があります。Exchange 2010のC#とpowershell - 'Group-Object'という用語が認識されない
私はC#で同じことをしようとした場合、私は選択-オブジェクトを使用している場合は、私は、私が得る、しかしGet-Mailbox -Server Exc2010 | Group-Object Database | Select-Object name,count
Name Count
---- -----
DB01 16
DB04 3
DB02 2
DB03 5
、
The term 'Group-Object' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
を
//Running cmdlets remotely
WSManConnectionInfo wsConnectionInfo = new WSManConnectionInfo(new Uri("https://" + ExchangeSite + "/powershell"),
"http://schemas.microsoft.com/powershell/Microsoft.Exchange", getCredential());
wsConnectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
wsConnectionInfo.SkipCACheck = true;
wsConnectionInfo.SkipCNCheck = true;
wsConnectionInfo.SkipRevocationCheck = true;
rsRemoteRunspace = RunspaceFactory.CreateRunspace(wsConnectionInfo);
rsRemoteRunspace.Open();
Collection<PSObject> Result = null;
Pipeline pipeLine = rsRemoteRunspace.CreatePipeline();
Command myCommand = new Command("Get-MailboxDatabase");
myCommand.Parameters.Add("Server", "Exc2010");
Command myCommand2 = new Command("Group-Object");
myCommand2.Parameters.Add("Property", "Database");
pipeLine.Commands.Add(myCommand);
pipeLine.Commands.Add(myCommand2);
Result = pipeLine.Invoke();
これを実行することができますPowerShellで
それは正常に動作するので、なぜ私はグループオブジェクトを使用してそのエラーを取得しているのだろうかと思う。
ご協力いただければ幸いです。
EDIT
私が選択-オブジェクトを使用してそれを実行した場合、それが正常に動作します:
Command myCommand = new Command("Get-MailboxDatabase");
myCommand.Parameters.Add("Server", "Exc2010");
Command myCommand2 = new Command("Select-Object");
myCommand2.Parameters.Add("Property", "Name");
pipeLine.Commands.Add(myCommand);
pipeLine.Commands.Add(myCommand2);
Result = pipeLine.Invoke();
PSObject PSResult = Result.FirstOrDefault();
Console.WriteLine("DB Name: " + PSResult.Properties["Name"].Value.ToString());
私が得る、
DB Name: DB01
あなたはより多くのコードを共有することはできますか? –
@ ShayLevy、コードを追加しました。ありがとう – m0dest0
あなたはselect-objectを使用できますか? –