Can I supply a version of powershell to be used on the target machine while ps remoting.
May be my question is not proper or not possible to answer but if any body having idea please help me.
I am trying to do a remoting using powershell on a machine where powershell 2.0 3.0 and 4.0 versions are available , but I want to use the version 4.0 only (on target machine) is it possible?
Thanks Gyan
Yes, there is a way to connect to a specific version of Powershell on a remote machine. It does require changes to be made on the remote machine though.
When you use Powershell remoting to make a connection, you are always connecting to a specific profile on the other end. Typically this profile is called
Microsoft.Powershell
, but other products create their own endpoints, like Exchange for example.You can create your own profiles, called session configurations, setting various settings, including the Powershell version.
The way to do this is to first create a session configuration file using
New-PSSessionConfigurationFile
and then register it on the target machine usingRegister-PSSessionConfiguration
.The version can be sepcified in both places (the value in
Register-PSSessionConfiguration
takes precedence) but only needs to be specified in one place.Once you've got the session you want on the target machine, use
New-PSSession
with the-ConfigurationName
parameter to create the session, and useInvoke-Command
with the-Session
parameter to pass the result ofNew-PSSession
.