PowerShell ve invoke-command

Sep 03 2020

Yardıma ihtiyacım olan en az iki sorunum var.

Kısa ve uzun adlar: Serveradmin ve Serveradmin.company.com üzerinde bir nslookup yapabilir ve her ikisi için de iyi bir IP adresi alabilirim.

Problem 1: Bunu yaparsam şunu alırım:

Invoke-Command -ComputerName Serveradmin -ScriptBlock {Get-PSDrive | Nerede {$ _. Ücretsiz -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

Bu komut satırı kısa veya uzun adla çalışmaz.

Problem 2: Şimdi bunu yaparsam şunu elde ederim (SessionOption ile):

Invoke-Command -ComputerName Serveradmin -SessionOption (New-PSSessionOption -ProxyAccessType NoProxyServer) -ScriptBlock {Get-PSDrive | Nerede {$ _. Ücretsiz -gt 0}}

İyi veriler alıyorum.

Uzun adı (Serveradmin.company.com) kullanmaya çalışırsam şu hata mesajını alıyorum:

[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

S3: "Proxy", internet web erişimi için kullandığımız proxy sunucusuna eşit mi?

Biri bana bu konularda yardım edebilir mi? Hem kısa hem de uzun isimler kullanmayı çok isterim.

GÜNCELLEME: https://www.pdq.com/powershell/new-pssessionoption/#ProxyAccessType Bu referansı buldum:

Determines which mechanism is used to resolve the host name. 

Komut dosyalarımı değiştirmeden tüm komut dosyalarında "NoProxyServer" ı nasıl zorlayabileceğime dair bir fikriniz var mı?

Yanıtlar

i2D Sep 03 2020 at 16:51

Uzak sunucuda Anti-virüsünüzü devre dışı bırakın ve "Invoke-Command -ComputerName Serveradmin -ScriptBlock {Get-PSDrive | Where {$ _. Free -gt 0}}" öğesini yeniden çalıştırın

Anti-virüs, HTTP isteklerini engelleyebilir ve AV'nizde hangi yapılandırmanın değiştirilmesi gerektiğini belirlemeniz gerekir.

Daha fazla bilgiyi burada görün: https://mikefrobbins.com/2012/06/21/welcome-to-powershell-hell/