C (Exchange 2013) get-mailboxdatabasecopystatus -databasename
을 어떻게 실행할 수 있습니까?C sharp에서 Exchange 셸 명령을 실행하는 방법?
나는 많은 조합을 시도하고 그들 모두는, 가장 최근의 존재 실패 : 여기
string un = @"domain\username";
System.Security.SecureString pw = new System.Security.SecureString();
string password = "password";
foreach (char ch in password)
{
pw.AppendChar(ch);
}
PSCredential cred = new PSCredential(un, pw);
PowerShell ps = PowerShell.Create();
string cmdlet = "Get-MailboxDatabaseCopyStatus database1";
ps.AddCommand("Set-Variable");
ps.AddParameter("Name", "cred");
ps.AddParameter("Value", cred);
ps.AddScript(@"$session = New-PSSession -configurationname microsoft.exchange -connectionuri http://exchangeserver.com/powershell -auth kerberos -credential $cred");
//ps.AddScript(@"Import-PSSession $session");
ps.AddScript(@"$a = Invoke-Command -Session $s -ScriptBlock {" + cmdlet + "}");
ps.AddScript(@"Remove-PSSession -Session $s");
ps.AddScript(@"echo $a");
foreach (PSObject result in ps.Invoke())
{
MessageBox.Show(result.Members.ToString());
}
오류가 있습니까? 뭐가 문제 야? – DLeh
$ session = New-PSSession -configurationname Microsoft.exchange-connectionuri http://exchangeserver.com/powershell-auth kerberos -credential $ cred "라는 용어는 cmdlet, 함수, 스크립트 파일 또는 작동 가능 프로그램의 이름으로 인식되지 않습니다. 프로그램 이름의 철자를 검사하거나 경로가 포함되었는지 경로가 올바른지 확인하고 다시 시도하십시오 다음은 포함 및 dll을 사용하고 있습니다. – Jay
get-mailboxdatabasecopystatus, 내가 조정할 수있는 것은 매우 도움이 될 것입니다. – Jay