1

Exchange PowerShell に接続するための次のコマンドがあります。C# を使用して接続しますが、最後の行 でImport-PSSession $Sessionサイトがクラッシュし、デバッガーに移動します。

$password = ConvertTo-SecureString -AsPlainText -Force mypassword;$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist me@mail.net,$password;$LiveCred = Get-Credential -Credential $mycred;$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlookurlforpowershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection; Import-PSSession $Session

ここに私のC#コードがあります:

private void initconnection(string text){

    Runspace rs = GetRunspace();
    Pipeline cmd = rs.CreatePipeline(text);
    Collection<PSObject> results = cmd.Invoke();
}

initconnection("$password = ConvertTo-SecureString -AsPlainText -Force Maxipereyra15;$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist cpereyra@crescentmortgage.net,$password;$LiveCred = Get-Credential -Credential $mycred;$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic –AllowRedirection; Import-PSSession $Session");

この問題を解決するにはどうすればよいですか?

4

0 に答える 0