Quantcast
Channel: Windows PowerShell Forum
Viewing all articles
Browse latest Browse all 2562

Add-pssnapin failing through pssession

$
0
0

Hi guys, Im very new to powershell so this may be an obvious fix for someone!

Basically I have a script which uses the enter-pssession to connect to a remote server.

Then attempting to add a snapin through the add-pssnapin command to load a snapin which provides the functionality to do remote tasks on the server (Running MS Dataprotection manager)

The problem from what I can tell is that the script connects to the remote server successfully but then runs the add-pssnapin locally rather then within the pssession, therefore resulting in the add-pssnapin command being unable to find the snapin ive referred to.

However, once the script has finished (and failed), I am then able to manually run the add-pssnapin command successfully.

My code is:

$credential = get-credential
enter-pssession -computername SERVER -authentication credssp -credential $credential
add-pssnapin microsoft.dataprotectionmanager.powershell

And heres the result when I try to call it (As you'll see after it failed I was able to manually run the command which then worked)

 

Any help would be greatly appreciated!


MCITP Windows 7 Enterprise Administrator

Viewing all articles
Browse latest Browse all 2562

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>