powershell : i cant open remote session without specify the FQDN anymore

泪湿孤枕 提交于 2019-12-02 22:13:39

问题


Some days ago, i was able do create a remote session using short name of the remote server/workstation.

This doesnt work anymore error is :

+ CategoryInfo : InvalidArgument : (computername1:String) [Enter-PSSession], PSRemotingTransportExcepti + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

but when i use the complete domain name it is working : nsn computername1.domain.com

Dns resolution is correct, what else can i check to troubleshoot this problem ?


回答1:


I've finaly found it ! :)

I had to modify the default pssession option and set the proxy to 'NoProxyServer' instead of the default value 'none'

so I added this line in my profile :

$PSSessionOption = New-PSSessionOption -ProxyAccessType NoProxyServer  

From technet :

None The proxy access type is not specified. This means that proxy information, such as the access type, authentication mechanism, and credential, is not passed to the Web Services for Management (WSMan) protocol service. This field is introduced in Windows PowerShell 2.0.

NoProxyServer No proxy server is used when configuring proxy settings. This mechanism resolves all the host names locally. This field is introduced in Windows PowerShell 2.0.




回答2:


As i cant find the source of the problem here is my workaround : rename the two aliases nsn and etsn and replace them by these functions in my profile :

rename-item alias:\nsn nsn2 -ea silentlycontinue
rename-item alias:\etsn etsn2 -ea silentlycontinue

function resolve-hostname{
    param($computername)
    [System.Net.Dns]::GetHostEntry($computername) |select -ExpandProperty hostname 
}

function nsn{
    param($computername)
    $cn=resolve-hostname $computername
    new-pssession -cn $cn
}

function etsn{
    param($computername)
    $cn=resolve-hostname $computername
    enter-pssession -cn $cn
}


来源:https://stackoverflow.com/questions/22613497/powershell-i-cant-open-remote-session-without-specify-the-fqdn-anymore

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!