2017-04-19 2 views
0

私はローカルホストへのリモートセッションを開くスクリプトを持っています。 ログオンスクリプトの中からいくつかのデバイスに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} 

私は、私は次のエラーを取得するこれを実行しようとするたび:後

winrm quickconfigは何も変更しない実行
 
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 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

ローカルホストに接続できるようにWinRM TrustedHostsを更新しましたか? – TessellatingHeckler

答えて

0

誰かがファイアウォールを改ざんしていた問題がありました。

基本的に、ファイアウォールのGPOがリモート管理をブロックしていました

+0

Docschnitzelサイトにようこそ。さらに、元の質問に対する正しい答えをユーザーが試してマークすることができます。あなたは何とか@Moewaldsの答えが正しかったとは思っていますが、あなたはそれがうまくいかなかったとのコメントを書いています。あなたの問題を解決するために何をしましたか?いったん自分の答えを正しいものとしてマークすることができると説明します。 –

+0

頭がおかげでありがとう、私は自分の答えをクリアし、数時間後に答えとしてそれを作ります(サイトでそれをマークすることができます) – Docschnitzel

0

winrmサービスが動作しているかどうかを確認してくださいあなたはlocalhost:

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

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

あなたがWinRMの経由で設定したとEnable-PSRemotingを経由してPSリモーティングを有効にしているもののそれ以外の場合はPSリモーティングは、動作しません。

+0

これはすでに実行中です。ありがとう:) 私はまだ深く掘り起こす必要があります。 – Docschnitzel

関連する問題