Hi
I've written the script below which reads the contents of a file from the network and write this to a users "adm-CustomAttributeText1" field.
The code works as expected up to the point where I use the SetInfo when nothing is actually written to the users object.
#Read the message from the text file
$File = "path to file.txt"
[string]$Tip = Get-Content $File
#Check the message is short enough, truncate and warn the user if it isn't. Set the message it if is.
if ($Tip.Length -gt 175) {
$Temp = "You can only use 175 characters for this message. Your message has been truncated as follows, please remove this line, edit and save your message again.`r`n" + $Tip.SubString(0, 175)
Set-Content -Path $File -Value $Temp
} Else {
$Context.TargetObject.Put("%adm-CustomAttributeText1%",$Tip)
$Context.TargetObject.SetInfo
}
I know that the Put is working, because of I add the following line to the script after the put, I get the value back:
Set-Content -Path "Path to another file.txt" -Value $Context.TargetObject.Get("%adm-CustomAttributeText1%")
If I use brackets after the SetInfo (as per the examples) then I just get a message 'Exception calling "SetInfo" with "0" argument(s).'
If I try putting the attribute name (or anything else) in the brackets then I get an error that there is no overload for a single argument.
Without the brackets the script seems to be happy and runs, but the value is not written to the attribute.
Any help would be greately appreciated.
Thanks