在我学习PowerShell的过程中,我偶然发现了令我困惑的事情。 我真的不明白为什么有时我必须使用
New-PSSession -ComputerName "servername"而有时候
New-PSSession -ConnectionUri "http://FQDN/powershell" etc...我无法找到这两种方法的明确解释。 究竟有什么区别?
In my quest of learning PowerShell I stumbled across something that confuse me. I don't really understand why sometime I have to use
New-PSSession -ComputerName "servername"and sometime instead
New-PSSession -ConnectionUri "http://FQDN/powershell" etc...I couldn't find a clear explanation of the two approaches. What is exactly the difference?
最满意答案
New-PSSession正在使用PSremoting,应在使用前进行配置。 配置意味着您可以为每台计算机略微区别。 最简单的示例是不同的端口和不同的端点名称。 Uri格式如下: <Transport>://<ComputerName>:<Port>/<ApplicationName>
对于默认配置,您只需要传递ComputerName并且将对所有其他值传递默认值。
但是,如果您具有非默认配置,则可以选择:
ConnectionURI与所有数据一起传递 使用ComputerName以及UseSSL , Port和ApplicationName参数指定ConnectionURI值。因此,只有两种方法可以将相同的信息传递给命令。
在您的示例中,您可以:
New-PSSession -ConnectionUri "http://FQDN/powershell"要么
New-PSSession -ComputerName "FQDN" -UseSSl $false -ApplicationName "powershell"两者的行为完全相同
New-PSSession is working over PSremoting, which should be configured before use. Configuration means that you can do it slightly differently for each of the computers. The simplest examples are different ports an different endpoint names. Uri format is as follows: <Transport>://<ComputerName>:<Port>/<ApplicationName>
For default configuration you need to pass only ComputerName and default values will be taken for all the other values.
If, however, you have non default configuration, you have a choice:
Pass ConnectionURI with all the data UseComputerName, together with UseSSL, Port, and ApplicationNameparameters to specify the ConnectionURI values.So it's just 2 ways of passing the same information to command.
In your example you could do:
New-PSSession -ConnectionUri "http://FQDN/powershell"or
New-PSSession -ComputerName "FQDN" -UseSSl $false -ApplicationName "powershell"Both will behave exactly the same
更多推荐
发布评论