This topic contains 4 replies, has 3 voices, and was last updated by
October 13, 2017 at 6:11 pm #82030ParticipantPoints: -16Rank: Member
I'm trying to test out some remote commands on a server and it's not letting me import the commands to the current session, even when I use a prefix.
The code I'm currently using is shown below:
$session = new-pssession -computername server01 import-pssession -session $session -prefix remote
This runs for about 2 or 3 seconds, and then starts spitting out a bunch of errors all in a row that all say the same thing:
import-pssession : Proxy creation has been skipped for the '%' command, because Windows PowerShell could not verify the safety of the command name.
There are probably around 25 of the same thing popping up in red text like this. Then, it finishes, and when I run the -verbose command, it says it skipped proxy creation of almost every command.
What is going on? I'm running it with a prefix, so it shouldn't be clashing. I shouldn't need to use the clobber parameter because it shouldn't be rewriting the computer commands. So why isn't it importing?
Thank you for your help.
October 13, 2017 at 6:19 pm #82031KeymasterPoints: 1,811Rank: Community Hero
I don't think I've ever tried important all several-hundred default commands from a remote session. You usually only import a module's worth. Can I ask what the use case is? Re-importing a remote Where-Object, for example, doesn't seem to have a lot of value...?
October 13, 2017 at 6:23 pm #82033ParticipantPoints: -16Rank: Member
I essentially want to be able to use every command for that particular server from my current powershell session.
I'm mostly curious as to how this works, because I was recently at a conference where Jason Helmick did it himself. He was able to import an entire powershell session with the prefix "Jason". He didn't specify a module. I wanted to see how that would work, so when I attempted it myself, I got these errors.
When you say you only import a module's worth, what exactly do you mean, and how would I do that?
Thanks for your reply!
October 13, 2017 at 6:31 pm #82034KeymasterPoints: 1,811Rank: Community Hero
Yeah, that'll not work pretty spectacularly. Your machine would be serialism get and deserializing too much. If that's your goal, just use Invoke-Command. I'll tell Jason to stop showing people that because it's dumb. You're asking your computer to create literally thousands of proxy commands locally, many of which – as you're seeing – it can't determine the safety of.
You'd specify a module using -Module on Import-Session.
October 13, 2017 at 8:09 pm #82057ParticipantPoints: 1Rank: Member
Hi Coby! In my demonstration I used the -module parameter and imported the ActiveDirectory Module. I just want to be clear I didn;t import everything from the remote machine, just the specific modules I needed. So choose a couple of modules you want and specifics them with -Module. Normally, I import one, then run the import line again to import another.
Hope that helps!
The topic ‘Import-session prefixes not working’ is closed to new replies.