views:

16

answers:

1

I'm trying to pass some arguments into a new Powershell remoting session using the PSSessionOption's ApplicationArguments property. Unfortunately, the arguments don't seem to show up.

Here's the code:

$client = "Bubba"
$options = New-PSSessionOption -ApplicationArguments @{ Client = $client }

Enter-PSSession -ComputerName "Server" -SessionOption $options

$clientName = $PSSenderInfo.ApplicationArguments.Client
$dir = New-Item "c:\temp\$clientName" -type directory

Exit-PSSession

This results in an error: "NewNotImplementedException at offset 101 in file:line:column..."

Am I doing something wrong?

A: 

Apparently Enter-PSSession and Exit-PSSession don't work within a script! They're for interactive command-line use only. This explains the problem.

Brian Vallelunga