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
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:
ConnectionURI
with all the dataComputerName
, together with UseSSL
, Port
, and ApplicationName
parameters 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