0

コマンドレットを実行するためにオンラインで Exchange のリモート Powershell 接続を開く必要がある C# で .Net コンポーネントを作成しています。ただし、ローカル マシンとインターネットの間には Web プロキシ サーバーがあります。IE でプロキシ サーバーの設定を提供していません。リモート ランスペースを開くときに、どうにかして Web プロキシ サーバーの IP アドレスとポート番号を提供する必要があります。

私は次のコードを使用しています:

PSCredential credential = new PSCredential(userEmail, securePassword);

connectionInfo = new WSManConnectionInfo(new Uri("https://ps.outlook.com/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);

connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
connectionInfo.MaximumConnectionRedirectionCount = 2;               

runspace = RunspaceFactory.CreateRunspace(connectionInfo);
runspace.Open();

powershell.Runspace = runspace;

//Create the command and add a parameter
powershell.AddCommand("Get-MailboxFolderStatistics");
powershell.AddParameter("identity", sMailbox);
...
...
...
pipeline = remoteRunspace.CreatePipeline()
foreach (Command command in cmdlet.GetCommands())
{
   pipeline.Commands.Add(command);
}
commandResults = pipeline.Invoke();

Runspace オブジェクトの RunspaceconnectionInfo の ProxyAccessType、ProxyCredentials、ProxyAuthentication プロパティには何を指定すればよいですか。

IE でプロキシ設定を使用せずに Web プロキシ サーバー設定を提供することで、リモート ランタイム空間を開く方法はありますか。アプリケーションのユーザー インターフェイスを介して、プロキシ サーバーの IP とポートを API に渡したい

提案してください。

ありがとう、ガガン

4

2 に答える 2

0

たとえば、フィドラーで動作するようにプロキシを構成する場合は、次のようにできます。

PSSessionOption sessionOptions = new PSSessionOption();
sessionOptions.ProxyAccessType = ProxyAccessType.IEConfig;
sessionOptions.ProxyAuthentication = AuthenticationMechanism.Negotiate;
wsManConnectionInfoInstance.SetSessionOptions(sessionOptions);
于 2015-01-20T08:10:34.040 に答える
0

プロキシ設定は、New-WSManSessionOption を使用して構成できます。

http://technet.microsoft.com/en-us/library/hh849874.aspx

于 2013-11-11T10:29:59.093 に答える