PowerShell и команда вызова

Sep 03 2020

У меня как минимум две проблемы, с которыми мне нужна помощь.

Короткие и длинные имена: я могу выполнить nslookup на Serveradmin и Serveradmin.company.com и получить хорошие 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 | Где {$ _. Free -gt 0}}»

Антивирус может блокировать HTTP-запросы, и вам нужно будет выяснить, какую конфигурацию нужно изменить на вашем AV.

См. Дополнительную информацию здесь: https://mikefrobbins.com/2012/06/21/welcome-to-powershell-hell/