get-aduser – output specific properties dynamically

The [] index operator at the very end is not applied until after the predecing expression has resolved:

(get-aduser $user -property $attr[$i]).$attr[$i]
# is evaluated as
((get-aduser $user -property $attr[$i]).$attr)[$i]

Change it to:

(get-aduser $user -property $attr[$i]).($attr[$i])
# or 
(get-aduser $user -property $attr[$i])."$($attr[$i])"

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top