-1

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

briantist
  • 45,546
  • 6
  • 82
  • 127
  • 1
    Welcome to Stack Overflow! [What have you tried ?](http://mattgemmell.com/what-have-you-tried/) and moreover **what is your question?** – Loïc MICHEL Sep 25 '14 at 08:23
  • The question is like can we provide a specific version of powershell to be used on target machine while powershell remoting? – Gyan Deepak Dubey Sep 25 '14 at 08:28
  • Is it possible to run a command like "powershell -version 4.0 invoke-command -ComputerName xxx.xxx.xxx.xxx -credential (New-Object System.Management.Automation.PSCredential -argumentlist "xxxxxx",( ConvertTo-SecureString "xxxx" -AsPlainText -Force )) {Get-Help Suspend-Job}" – Gyan Deepak Dubey Sep 25 '14 at 08:30
  • Your question makes little sense. Please read about the [XY problem](http://xyproblem.info/) and consider updating the question with specific information. – vonPryz Sep 25 '14 at 08:39
  • you cant execute V4 version if V2 is install on the remote host if that is your question – Loïc MICHEL Sep 25 '14 at 08:40
  • Yes exactly you got my problem so its means the host and target shlud have the versions installed that can be used in remoting? – Gyan Deepak Dubey Sep 25 '14 at 08:45
  • @ vonPryz I hope now my question is clear to you? – Gyan Deepak Dubey Sep 25 '14 at 08:46
  • Please take a step back and describe the actual problem you're trying to solve instead of what you perceive as the solution. Why do you think you need to start a specific PowerShell version on the remote host instead of just using the most recent one (which is the default)? – Ansgar Wiechers Sep 25 '14 at 08:58
  • This is some how a requirement from one of our client in a product line , If it is possible to do this please let me know BTW the most recent version is always an options to be used. – Gyan Deepak Dubey Sep 25 '14 at 09:37
  • Without you somehow explaining what you actually want to achieve by doing this, we somehow can't help you. Have a nice day. – Ansgar Wiechers Sep 26 '14 at 08:46
  • As simple as I can say is : I want to execute some command using powershell remoting to a specific version of powershell on target machine let say version 3.0. Is it clear to you ? – Gyan Deepak Dubey Sep 26 '14 at 08:54
  • And more clearly, dose invoke command can execute a command on specific powershell version ? if yes where to provide this version. – Gyan Deepak Dubey Sep 26 '14 at 08:57
  • Frankly, I think this question is both clear and on topic and I'm not sure why there is so much confusion surrounding it. Answer forthcoming... – briantist Sep 27 '14 at 17:02

1 Answers1

4

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 using Register-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 use Invoke-Command with the -Session parameter to pass the result of New-PSSession.

briantist
  • 45,546
  • 6
  • 82
  • 127