OWA Email Signature

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 7 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
devereux0110
Posts: 38
Last visit: Mon Oct 02, 2017 7:11 am

OWA Email Signature

Post by devereux0110 »

We have worked out how to add a Signature to a single OWA Account using Variables from the individual users account as Powershell commands below

$Signature1 = Get-ADUser username -Properties Name | Select-Object name
$JobTitle1 = Get-ADUser username -Properties Description | Select-Object Description
$separator = "@{name="
$Signature1 = $Signature1 -split $separator
$separator = "}"
$Signature1 = $Signature1 -split $separator
$separator = "@{Description="
$JobTitle1 = $JobTitle1 -split $separator
$separator = "}"
$JobTitle1 = $JobTitle1 -split $separator
$SentbyOWA = "Sent by ORGANISATIONS NAME Web Outlook System"
$Signature1 = $Signature1 + "<br />"
$JobTitle1 = $JobTitle1 + "<br />"
$Signature = $Signature1 + $JobTitle1 + $SentbyOWA
Get-Mailbox -RecipientTypeDetails UserMailbox username | Set-MailboxMessageConfiguration -SignatureHTML $Signature -DefaultFontName "Century Gothic" -DefaultFontSize 3 -AutoAddSignature:$true


However trying to put this into a Powershell that searches thorugh all users in an OU and add this Signature to each of those accounts we are just failing at. Powershell modified below:
$users = Get-ADUser -SearchBase "OU=Staff,OU=Users,OU=BLA - St Catherines,DC=BLA,DC=ORG,DC=UK" -Filter * -Properties DisplayName, sAMAccountName, Description | select-object displayName, sAMAccountName, description
ForEach($u in $users) {
$Signature1 = $u | select-object sAMAccountName
$displayname1 = $u | select-object displayName
$JobTitle1 = $u | select-object description
$SentbyOWA = "Sent by ORGANISATIONS NAME Web Outlook System"
$displayname1 = $displayname1 + "<br />"
$JobTitle1 = $JobTitle1 + "<br />"
$Signature = $displayname1 + $JobTitle1 + $SentbyOWA
Get-Mailbox -RecipientTypeDetails UserMailbox $Signature1 | Set-MailboxMessageConfiguration -SignatureHTML $Signature -DefaultFontName "Century Gothic" -DefaultFontSize 3 -AutoAddSignature:$true
}


Not really sure where we are going wrong, tried loads of different suggestions out on the web but falling over each way

Any suggestions appreaciated

Regards
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: OWA Email Signature

Post by jvierra »

This is a better way using PowerShell.
  1. $template = '{0}<br />{1}<br />Sent by ORGANISATIONS NAME Web Outlook System'
  2. $ou = 'OU=Staff,OU=Users,OU=BLA - St Catherines,DC=BLA,DC=ORG,DC=UK'
  3. Get-ADUser -SearchBase $ou -Filter * -Properties DisplayName, Description |
  4.     ForEach-Object{
  5.         $signature = $template -f $_.displayName, $_.description
  6.         Get-Mailbox -RecipientTypeDetails UserMailbox $_.sAMAccountName |
  7.             Set-MailboxMessageConfiguration -SignatureHTML $signature -DefaultFontName 'Century Gothic' -DefaultFontSize 3 -AutoAddSignature:$true
  8.     }
User avatar
devereux0110
Posts: 38
Last visit: Mon Oct 02, 2017 7:11 am

Re: OWA Email Signature

Post by devereux0110 »

Thankyou very much, this worked brill
Much Appreciated,
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: OWA Email Signature

Post by jvierra »

You are welcome.

Spend a bit of time getting more familiar with how PS handles these things and your scripting will become much easier.
This topic is 7 years and 1 month old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked