Ah. That's because you need to also import the types.
-----Original Message-----
From: [email protected] [mailto:[email protected]] On
Behalf Of Joseph L. Casale
Sent: Wednesday, April 23, 2014 8:04 AM
To: '[email protected]'
Subject: RE: [Exchange] RE: Constrained pssessions
> Well, I was interested in the PowerSHell cmdlets. They are pretty well
> defined.
I am giving an object that contains all the potential attributes to set with
the given data. I pass the names and values to a switch, for example with
EmailAddresses it looks something like:
'EmailAddresses'
{
$return = New-Object Microsoft.Exchange.Data.ProxyAddressCollection
if ($Value -and $Value.Count -gt 0)
{
foreach ($i in $Value)
{
$return.Add($i)
}
}
return $return
}
Finally, these and the Identity is added to a hash and applied to the cmdlet:
Set-MailUser @params
The issue manifests where if you use the regular RemoteExchange.ps1 means to
setup a connection, that data type is available for new-object, yet when you
setup a possession and then import it, this data type is not available. Its not
an issue with cmdlets for exchange per se, but a nuance with a session,
$foo = New-PSSession `
-ConfigurationName Microsoft.Exchange `
-ConnectionUri ('http://{0}/powershell' -f $bar) `
-Credential $creds
....
Import-PSSession $foo
Thanks,
jlc