Author Posts

April 17, 2015 at 2:43 am

Hi there
I have some powershell code that is failing at this point

$ADAMUserDirectoryEntry.properties.proxyaddresses.add($ADAttributeValue)

This command works providing that there is already a proxyaddresses value. If there is not I get the following error

You cannot call a method on a null-valued expression.
At line:1 char:59
+ $ADAMUserDirectoryEntry.properties.proxyadeewewdresses.add < <<< ($ADAttributeValue) + CategoryInfo : InvalidOperation: (add:String) [], RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull ProxyAddresses Attribute is displayed in Attribute column of ADSIEdit though its value is $ADAMUserDirectoryEntries.properties does not display the proxyaddresses attribute [DBG]: PS C:\Users\Administrator>>> $ADAMUserDirectoryEntry.properties

PropertyName Value Capacity Count
———— —– ——– —–
objectClass {top, person, organizatio... 4 4
cn Owen Johns 4 1
distinguishedName CN=Owen Johns,OU=Z1,OU=St... 4 1
instanceType 4 4 1
whenCreated 14/04/2015 22:02:05 4 1
whenChanged 16/04/2015 16:36:10 4 1
uSNCreated System.__ComObject 4 1
memberOf CN=SEC-ES-COR-The AssetBa... 4 1
uSNChanged System.__ComObject 4 1
name Owen Johns 4 1
objectGUID {131, 71, 124, 223...} 4 1
objectSid {1, 5, 0, 0...} 4 1
objectCategory CN=Person,CN=Schema,CN=Co... 4 1
dSCorePropagationData 01/01/1601 00:00:00 4 1
uid Oj01 4 1
nTSecurityDescriptor System.__ComObject 4 1

Appreciate any help

April 17, 2015 at 3:51 am

The error is saying that $ADAMUserDirectoryEntry.properties.proxyadeewewdresses is null – specifically, ProxyAdeewewdresses. I'm not sure you've got that spelled right.

April 17, 2015 at 5:31 am

I have cracked it. Schoolboy error