2012-07-30 4 views
0

새 파일을 복사하기 전에 원격 서버의 폴더를 지워야합니다.Powershell 원격 통해 프록시 호출

그래서 내 클라이언트의 스크립트는 다음이 포함 :이 프로그램을 실행할 때 나는 다음과 같은 오류

Invoke-Command -Computer $TargetServer -ScriptBlock { Remove-Item $ClearPath } 

얻을 :이의 나의 이해는 내가 TechNet의이 고개를

Connecting to remote server failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests 

했다 서버가 프록시를 사용하는 경우 (인터넷에 연결하려고 시도 할 때), $ PSSessionOption 객체를 사용해야합니다.

$User = "group\tfs_service" 
$Password = ConvertTo-SecureString -String "x" -AsPlainText -Force 
$Credential = New-Object –TypeName System.Management.Automation.PSCredential –ArgumentList $User, $Password 
$PSSessionOption = New-PSSessionOption -ProxyAccessType IEConfig -ProxyAuthentication Negotiate -ProxyCredential $Credential 

를 이제 나는 다음과 같은 오류 얻을 스크립트를 실행할 때 : 내가 잘못거야 어디

Connecting to remote server failed with the following error message : The WinRM client cannot process the request. Setting proxy information is not valid when the HTTP transport is specified. Remove the proxy information or change the transport and try the request again 

사람이 말해 주시겠습니까를 그래서 나는 다음이 먼저 실행되도록 내 스크립트를 변경 ?

답변

0

내가 프록시를 구성 할 필요가 있다고 생각한 잘못된 트리를 짖고있는 것으로 보입니다. 유일한 문제는 필자가 원격 서버에서 원격으로 PowerShell을 사용하도록 설정하지 않았다는 것입니다.

이 PowerShell을 클라이언트와 원격 PowerShell은 서버 사이
Enable-PSRemoting 
1

통신이 프록시에 의해 도청을 피하기 위해 보안을 유지해야한다 (= 중간자 : 나는 높은 PowerShell 창에서 다음 명령을 실행하여이 작업을 수행 할 수 있었다), 이는 Powershell Remoting이 전송이 HTTPS 인 경우에만 프록시를 지원하는 이유입니다.

블로그 게시물 How To Use WSMan Proxy Support은 서버 측 HTTPS 수신기를 설정하는 방법과 프록시를 통해이 수신기에 연결하는 방법을 보여줍니다. 서버 측 HTTPS 리스너 일단

는 설정은, 다음과 같이 클라이언트에서 스크립트 블록을 호출하려고하고있다 :

Invoke-Command -Computer $TargetServer -ScriptBlock { Remove-Item $ClearPath } -sessionoption $PSSessionOption -UseSSL Authentication Basic -Credential $Credential 
0

당신은 다른 단절에의 WinRM은 QuickConfig을 실행하려고 했습니까? 스크립트가 목표로 삼고있는 winrm 수신기를 구성합니다.

관련 문제