2017-04-19 4 views
0

localhost에 대한 원격 세션을 여는 스크립트가 있습니다. NuGet을 로그온 스크립트 내에서 일부 장치에 설치하려면이 기능이 필요합니다.localhost에 대한 새 PSSession이 실패합니다.

$Username = "Admin" 
$Password = ConvertTo-SecureString ‘adminPW’ -AsPlainText -Force 
$adminCredential = New-Object System.Management.Automation.PSCredential $Username, $Password 
$Session = New-PSSession -Credential $adminCredential 
Invoke-Command -Session $Session -ScriptBlock {Install-PackageProvider -Name NuGet -Verbose -MinimumVersion 2.8.5.201 -Force} 

나는 다음과 같은 오류 얻을이 실행하려고 할 때마다 : 다음

 
New-PSSession : [localhost] Connecting to remote server localhost 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. Consult the logs and documentation for the 
WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the 
destination to analyze and configure the WinRM service: "winrm quickconfig". For more information, see the about_Remote_Troubleshooting Help topic. 
At C:\Users\Mike Holtackers\OneDrive - Foreign Trade Association\Scripts\OutlookSig\getAADconnectionOK.ps1:5 char:12 
+ $Session = New-PSSession -ConnectionUri $ConnectionURI -Credential $a ... 
+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    + CategoryInfo   : OpenError: (System.Manageme....RemoteRunspace:RemoteRunspace) [New-PSSession], PSRemotingTransportException 
    + FullyQualifiedErrorId : CannotConnect,PSSessionOpenFailed 

아무것도 변경되지 않습니다 winrm quickconfig 실행을 ...

winrm get winrm/config

 
PS WSMan:\localhost\Listener\Listener_1084132640> winrm get winrm/config 
Config 
    MaxEnvelopeSizekb = 500 
    MaxTimeoutms = 60000 
    MaxBatchItems = 32000 
    MaxProviderRequests = 4294967295 
    Client 
     NetworkDelayms = 5000 
     URLPrefix = wsman 
     AllowUnencrypted = false 
     Auth 
      Basic = true 
      Digest = true 
      Kerberos = true 
      Negotiate = true 
      Certificate = true 
      CredSSP = false 
     DefaultPorts 
      HTTP = 5985 
      HTTPS = 5986 
     TrustedHosts = * 
    Service 
     RootSDDL = O:NSG:BAD:P(A;;GA;;;BA)(A;;GR;;;IU)S:P(AU;FA;GA;;;WD)(AU;SA;GXGW;;;WD) 
     MaxConcurrentOperations = 4294967295 
     MaxConcurrentOperationsPerUser = 1500 
     EnumerationTimeoutms = 240000 
     MaxConnections = 300 
     MaxPacketRetrievalTimeSeconds = 120 
     AllowUnencrypted = false 
     Auth 
      Basic = false 
      Kerberos = true 
      Negotiate = true 
      Certificate = false 
      CredSSP = false 
      CbtHardeningLevel = Relaxed 
     DefaultPorts 
      HTTP = 5985 
      HTTPS = 5986 
     IPv4Filter = 194.168.254.1-194.168.254.256 [Source="GPO"] 
     IPv6Filter [Source="GPO"] 
     EnableCompatibilityHttpListener = false 
     EnableCompatibilityHttpsListener = false 
     CertificateThumbprint 
     AllowRemoteAccess = true [Source="GPO"] 
    Winrs 
     AllowRemoteShellAccess = true 
     IdleTimeout = 7200000 
     MaxConcurrentUsers = 2147483647 
     MaxShellRunTime = 2147483647 
     MaxProcessesPerShell = 2147483647 
     MaxMemoryPerShellMB = 2147483647 
     MaxShellsPerUser = 2147483647 
의 출력
+1

컴퓨터에서 Enable-PSRemoting을 실행 했습니까? –

+0

예, 있습니다. 폐하가 되려고했지만 다시 같은 결과가 나타납니다. – Docschnitzel

+1

localhost에 연결할 수 있도록 WinRM TrustedHosts를 업데이트 했습니까? – TessellatingHeckler

답변

0

누군가 방화벽을 변조 한 경우 문제가 발생했습니다 ... 도움을 주신 분들께 고맙습니다!

기본적으로 방화벽 GPO가 원격 관리를 차단했습니다.

+0

Docschnitzel 사이트에 오신 것을 환영합니다. 사람들을 더 쉽게 돕기 위해 원래 질문에 대한 올바른 대답을 시도하고 표시 할 수 있습니다. 나는 당신이 어떻게 든 @Moewalds 대답이 정확하다고 말한 것을 본다. 그러나 그것이 작동하지 않는다는 의견을 적었고, 방화벽 문제라고 진술 한이 다른 대답을 가지고있다. 문제를 해결하기 위해 무엇을 했습니까? 일단 자신의 대답을 올바른 것으로 표시 할 수 있다고 설명하면. –

+0

머리를 주셔서 감사합니다, 나는 내 자신의 대답을 정리하고 그것을 몇 시간 안에 대답으로 만들 것입니다 (사이트에서 나를 표시하게 할 때) – Docschnitzel

0

winrm 서비스가 실행되고 있는지 확인하십시오. 로컬 호스트 : 당신은 WinRM을 통해 구성한 및 Enable-PSRemoting를 통해 PS 원격를 활성화하지만

PS C:\> Get-Service winrm | ft -AutoSize 

Status Name DisplayName        
------ ---- -----------        
Running winrm Windows Remote Management (WS-Management) 

그렇지 않으면 PS 원격이 작동하지 않습니다.

+0

그것은 이미 실행 중입니다, 고마워요 :) 그래서 나는 더 깊이 두려워해야합니다. – Docschnitzel