Implicit remoting and non-string arguments

by KrisVG at 2012-10-12 03:09:28

Using implicit remoting I can do something like this:
$DCSession = New-PSSession -Computer MyDC01 #where 'MyDC01" is the fictitious name of a domain controller
Invoke-Command -Command {Import-Module ActiveDirectory} -Session $DCSession
Import-PSSession -Session $DCSession -Module ActiveDirectory

Set-ADUser -Identity “TestUser01” -Add @{OtherTelephone=“123456”}
Set-ADUser -Identity “TestUser01” -Add @{OtherTelephone=“123457”, “123458”}

The thing is that the first Set-ADUser line will work but the second won’t.
If you execute this on the DC directly it will work.

This makes me think that the implicit remoting doesn’t handle the array (passed in the hash table to update a multivalue argument of TestUser01).
The error will state that the parameter passed is of an invalid type (System.Management.Automation.PsObject)

Question: Is there a way to change multivalue attributes using impicit remoting?

PS: “Powershell in a Month of Lunches” states on page 209: “Hopefully you’ll encounter few (if any) objects with this limitation”, I think I just found one :frowning:
by DonJ at 2012-10-12 07:11:08
No, there’s something weirder. I can’t run that using Invoke-Command, either, which would send the entire command over without trying to parse it. I’m getting the same error that it doesn’t like the PSObject as a datatype, but I’m going to need to run a trace to find out where it’s getting that from.
by DonJ at 2012-10-12 07:24:20
It’s having an issue with PSObject being passed to the -InputObject parameter of the underlying Invoke-Command cmdlet. Somehow. That’s where the error is actually being raised from. It does a mandatory param check on Invoke-Command, called Beginprocessing, calls Endprocessing, and then starts barfing. So I mean, yeah, it obviously has something to do with how that hashtable is being handed off internally, but I can’t see why. It definitely fails if I explicitly remote the same thing, so it isn’t the proxy function per se.

Invoke-Command -Session $s -ScriptBlock { Set-ADUser -Identity DonJ -Add @{‘OtherTelephone’=‘1234’,‘5678’} }

Fails the exact same way. I’m gonna try and get someone else to take a look at this. Stay tuned.
by DonJ at 2012-10-12 11:12:59
K. This officially looks like a bug. You’re going to need to log it at under the PowerShell program, so that the team can evaluate it.
by KrisVG at 2012-10-14 01:07:28
Mr Jones,

If you think it’s a bug, I’ll open a support call for it using our company’s volume license contract. I’ll post results here when I get answers from Microsoft.
Thanks for the investigation.