GetDirectoryEntry
(1)
ADrectoryEntry
(1)
GetDi
(1)
PutEx
(1)
ProxyAddresses
(1)
ObjectCategory
(1)
ObjectClass
(1)
Dumas
(1)

Updating AD proxyAddresses

Asked By ShawnDuma
13-Sep-07 08:12 PM
param ([array]$users=$(throw "Need Users..."))
foreach ($user in $users)
{
$u = (ldap
if ($u.proxyAddresses)
{
$pa = $u.proxyAddresses | ?{$_ -match 'bad-address'}
$pa = '@("' + ([string]::join('","', $pa)) + '")'
$u.PutEx(2, 'proxyAddresses', (invoke-expression "$pa"))
$u.SetInfo()
}
}

This works but why on earth do I have to get so jiggy with the array before
PutEx will take it?

Updating AD proxyAddresses

Asked By Oisin Grehan
13-Sep-07 08:20 PM
On Sep 13, 8:12 pm, Shawn Dumas <ShawnDu...@>
re

I remember going through similar hoops trying to get arrays as
parameters passed correctly; a bit painful. I still muck it up now and
again. Powershell has a habit of unrolling arrays before passing them
anywhere, so try using the array constructor:

$pa =3D $u.proxyAddresses | ?{$_ -match 'bad-address'}
$u.PutEx(2, 'proxyAddresses', (,$pa))

I'm not able to test this, so it might not work outright, but
Hopefully it'll give you some ideas. So, why do this? By putting the
array constructor in front of it, I'm making an array with 1 element,
which is your $pa array. Powershell will unroll it, leaving the inner
array intact (hopefully!)

Hope this helps

- Oisin

Updating AD proxyAddresses

Asked By ShawnDuma
13-Sep-07 08:28 PM
I will give that a shot, thanks!

I would assume it because that is a multi value attribute and with

Asked By Brandon Shell
13-Sep-07 08:26 PM
I would assume it because that is a multi value attribute and with
ADS_PROPERTY_UPDATE (aka 2) it expects an arrayish value.

Are you trying to replace all the values or just one particular one?
Try adding [array] in front of $pa[array]$pa = $u.proxyAddresses | ?
Asked By Brandon Shell
13-Sep-07 08:32 PM
Try adding [array] in front of $pa
[array]$pa = $u.proxyAddresses | ?{$_ -match 'bad-address'}
$pa += New-Value
$u.PutEx(2, 'proxyAddresses', $pa)
$u.setinfo()
$u.
Asked By ShawnDuma
13-Sep-07 08:40 PM
$u.PutEx(2, 'proxyAddresses', (,"$pa"))

All I had to do was add quotes to what you posted and then, pow; it worked!
Thanks again.
Updating AD proxyAddresses
Asked By ShawnDuma
13-Sep-07 08:44 PM
I am replacing.
Post Question To EggHeadCafe