AD Notes field, data type issue?


whenever organization creates new security group in ad, in notes field add 4 lines of text. contact, email, authorization, , audit trail. these lines displayed 1 item per line. am successfully getting these variables user running script, , can display them on screen 1 item per line, when try insert ad security group notes field error. code , error below.

 

  import-module activedirectory  $ad_group_name = read-host "enter new security group name"  $ad_group_description = read-host "enter new group description"  $ad_audit_contact = read-host "enter ad audit contact"  $ad_audit_email = read-host "enter ad audit email"  $ad_audit_auth = read-host "enter ad audit auth"  $ad_audit_audit = read-host "enter ad audit trail information"  $ad_audit_complete_text = -join $ad_audit_contact, $ad_audit_email, $ad_audit_auth, $ad_audit_audit    #create new group  new-adgroup -name $ad_group_name -groupscope global -path "<my ad path>" -description $ad_group_description -otherattribute @{'info'= $ad_audit_complete_text}    #add member(s) group  $new_group_member = read-host "enter group member add"  add-adgroupmember -identity $ad_group_name -member $new_group_member    do  {  $answer_more_group_members = read-host "would add member? (y/n)"  $answer_more_group_members = $answer_more_group_members.toupper()  if ($answer_more_group_members -eq "y") {$new_group_member = read-host "enter group member add"  add-adgroupmember -identity $ad_group_name -member $new_group_member}  }  while ($answer_more_group_members -eq "y")  

 

the error this:

new-adgroup : cannot bind parameter 'otherattributes' target. exception setting "otherattributes": "parameter: 'otherattributes' requires values in collection of same type."

at \create ad group.ps1:11 char:181

+ new-adgroup -name $ad_group_name -groupscope global -path "<my ad path>" -description $ad_group_d

escription -otherattribute <<<<  @{'info'= $ad_audit_complete_text}

    + categoryinfo          : writeerror: (:) [new-adgroup], parameterbindingexception

    + fullyqualifiederrorid : parameterbindingfailed,microsoft.activedirectory.management.commands.newadgroup

 

if not use "-join" function/method give myself line feed, works fine although text 1 long line don't want. think issue text isn't considered pure text after use -join command on it.

ideas?

thank you! 

in vbscript, used vbcrlf , worked fine. after experimentation found `r`n works in powershell strings. carriage return followed new line (line feed).

 


richard mueller - mvp directory services


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group