Appending line to info attribute with Powershell


have of had append text info attribute in active ms cmdlets? super easy quest ad cmdlets. doing set-aduser -identity $cn -add @{"info"=$text} . complains attribute can have on value. i have tried:

$currentnotes =  get-aduser -identity $cn  -properties info    $newnote = (get-date -format g) + ' - ' + $text + '  ' + $currentnotes.info    	if ($currentnotes.length -gt 1024)  	{  		$newnote = $currentnotes.substring(0,1024)  	}  		  	set-aduser -identity $cn -add @{'info'=$newnote}
suggestions
 

since you're getting current value, appending new details , writing ad should use -replace rather -add end :

set-aduser -identity $cn -replace @{'info'=$newnote}
full details of set-aduser here http://technet.microsoft.com/en-us/library/ee617215.aspx not importantly fact each of them can use -replace, -clear , -remove parameters -add.



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