Welcome › Forums › General PowerShell Q&A › ADUser Properties
I’ve been adapting this script: https://dev.to/jcoelho/how-to-deploy-email-signatures-through-group-policies-4aj1
My script is very similar but there is one ADU property giving me problems. That is mobile phone ($ADUser.mobile).
If I set $mob=ADUser.mobile in the script it gets no value.
If I Write-Host $ADUser.mobile I get the correct value.
My template file contains the line
<td colspan=”2” class=”style2“>Mobile: PHONE2
My script has
$mobilePlaceHolder = “PHONE2”
$signature = $rawTemplate -replace $mobilePlaceHolder,$ADUser.mobile
This gives no mobile number in the html file. The page source confirms that PHONE2 has gone but nothing replaces it.
If I assign $mob=$ADUser.mobile and then replace using $mob I get the same result.
In a Powershell session assigning $mob to $ADUser.mobile works fine, just not in the script.
Any help much appreciated.
This seems to work:
<em>$signature = $rawTemplate.Replace('PHONE2', $ADUser.Mobile)</em>
Keep in mind, the .Mobile property must contain a value.