何时使用

编程入门 行业动态 更新时间:2024-10-24 04:42:09
何时使用-ComputerName和-ConnectionUri?(When to use -ComputerName and when -ConnectionUri?)

在我学习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

更多推荐

本文发布于:2023-08-07 18:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465063.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!