0

I need my local $profile located on my local PC to be loaded automatically when I PSRemote into other computers. My $profile also imports a few local modules (available only on my local PC). So, I need my $profile to be enhanced so that my modules can be still be imported (regardless where my $profile is loaded).

I spent a lot of time trying to get this to work; but see a lot of inconsistent information posted (probably because the differences between PS2 and PS3). Everything I tried, resulted in some kind of error.

I was hoping someone would help me with a dummy-proof working example of how to do this. The only thing that actually works is a basic: enter-pssession -ComputerName RemoteServerName. I did try to at least get my local profile to load in a remote session (see below), but that didn't work either; let alone loading the modules imported in the profile file.

Register-PSSessionConfiguration -Name MyLocalProfile -StartupScript $Profile
Enter-PSSession -ComputerName REMOTESERVERNAME -ConfigurationName 'MyLocalProfile'

Gives error:

Enter-PSSession : Connecting to remote server REMOTESERVERNAME failed with the following error message : The WS-Management service cannot process the request. Cannot find the MyLocalProfile session configuration in the WSMan: drive on the REMOTESERVERNAME computer.

I even tried:

Register-PSSessionConfiguration -Name MyLocalProfile `
          -StartupScript \\MYLocalPC\profile$\Microsoft.PowerShell_profile.ps1

But, but it still produced the same error. Not sure why it should be this hard to do something that most people would most likely want to happen by default.

MKANET
  • 573
  • 6
  • 27
  • 51

1 Answers1

0

Short answer: You're doing it incorrectly, and it's impossible to do it that way.

Long Answer:

From the Enter-PSSession page on MSDN, a line stands out:

The session configuration for a session is located on the remote computer. If the specified session configuration does not exist on the remote computer, the command fails.

Therefor you will have to Invoke-Command the Register-PSSessionConfiguration before creating the new session.

Eris
  • 7,378
  • 1
  • 30
  • 45
  • It looks like I didn't do a very good job of explaining the problem. I started a new StackOverflow question that's much more concise; describing exactly what I've tried already; and, what specifically I can't do. http://stackoverflow.com/questions/20130842/powershell-3-0-importing-binary-module-from-remote-share – MKANET Nov 21 '13 at 20:06
  • Then please consider deleting this question. – Lars Truijens Nov 24 '13 at 13:25