active directory - filling attribute with concatenated string -
i looking way concatenate string , put in 1 active directory user account object, precise, in altsecurityidentities. value input following: " constant, , (firstname)(whitespace)(lastname) (custom value can taken attribute, in form x.yyyyyyyy.z (what matters me yyyyyyy part (.substring(2,8)) works charm here. i'd several accounts listed in variable of type typename: microsoft.activedirectory.management.aduser. can set accounts under $accounts variable. far have code create attribute value 1 account listed in there: $accounts | %{'constant value'+$.givenname+' '+$.surname+' '+'('+$(($_.attributename).substring(2,8))+')'} this, i'd put in altsecurityidentities attribute value, log event viewer success , errors
you're there need apply value desired field:
$accounts | foreach-object { set-aduser -identity $_ -add @{altsecurityidentities = "constant value $($_.givenname) $($_.surname) ($($_.attributename.substring(2,8)))"} }
i have tidied code embedding variables in string rather using concatenation, cleaner.
Comments
Post a Comment