PowerShell 및 invoke-command

Sep 03 2020

도움이 필요한 문제가 두 가지 이상 있습니다.

짧은 이름과 긴 이름 : Serveradmin 및 Serveradmin.company.com에서 nslookup을 수행하고 둘 다에 대해 좋은 IP 주소를 얻을 수 있습니다.

문제 1 : 이렇게하면 다음과 같은 결과가 나타납니다.

Invoke-Command -ComputerName Serveradmin -ScriptBlock {Get-PSDrive | 여기서 {$ _. Free -gt 0}}

[Serveradmin] Connecting to remote server Serveradmin failed with the
following error message : WS-Management cannot process the request.
The operation failed because of an HTTP error. The HTTP error (12152)
is: The server returned an  invalid or unrecognized response . For
more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (Serveradmin:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : WinRMOperationAborted,PSSessionStateBroken

이 명령 줄은 짧거나 긴 이름에서 작동하지 않습니다.

문제 2 : 이제 이것을하면 (SessionOption으로) 이것을 얻습니다.

Invoke-Command -ComputerName Serveradmin -SessionOption (New-PSSessionOption -ProxyAccessType NoProxyServer) -ScriptBlock {Get-PSDrive | 여기서 {$ _. Free -gt 0}}

좋은 데이터를 얻습니다.

긴 이름 (Serveradmin.company.com)을 사용하려고하면 다음 오류 메시지가 표시됩니다.

[Serveradmin.lmms.lmco.com] Connecting to remote server lc1admin.lmms.lmco.com failed with the following error message : WinRM cannot process the request. The following error occurred while using Kerberos authentication: Cannot find 
the computer Serveradmin.lmms.lmco.com. Verify that the computer exists on the network and that the name provided is spelled correctly. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (Serveradmin.lmms.lmco.com:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : NetworkPathNotFound,PSSessionStateBroken

Q3 : "프록시"는 인터넷 웹 액세스에 사용하는 프록시 서버와 동일합니까?

누구든지 이러한 문제로 나를 도울 수 있습니까? 짧은 이름과 긴 이름을 모두 사용하고 싶습니다.

최신 정보: https://www.pdq.com/powershell/new-pssessionoption/#ProxyAccessType 이 참조를 찾았습니다.

Determines which mechanism is used to resolve the host name. 

스크립트를 수정하지 않고 모든 스크립트에서 "NoProxyServer"를 강제 할 수있는 방법이 있습니까?

답변

i2D Sep 03 2020 at 16:51

원격 서버에서 안티 바이러스를 비활성화하고 "Invoke-Command -ComputerName Serveradmin -ScriptBlock {Get-PSDrive | Where {$ _. Free -gt 0}}"을 다시 실행합니다.

안티 바이러스는 HTTP 요청을 차단할 수 있으며 AV에서 변경해야하는 구성을 파악해야합니다.

여기에서 추가 정보를 참조하십시오. https://mikefrobbins.com/2012/06/21/welcome-to-powershell-hell/