PowerShell/Exchange
Exchange et l'automatisation.
Création d'une signature pour tous les comptes
Création d'une signature au format HTML pour tous les comptes récupérés de l'AD.
#set folder location for files, the folder must allready exist
$save_location = 'file_location'
$email_domain = '@bigcheese.com'
#connect to O365 tenant
$Cred = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell/ -Credential $Cred -Authentication Basic –AllowRedirection
Import-PSSession $Session
#Get a list of all the filenames in the target folder
$sig_files = Get-ChildItem -Path $save_location
#Now push the html to the users signature
foreach ($item in $sig_files) {
$user_name = $($item.Basename) + $email_domain
$filename = $save_location + $($item.Basename) + ".htm"
Write-Host "Now attempting to set signature for " $user_name
set-mailboxmessageconfiguration -identity $user_name -signaturehtml (get-content $filename) -autoaddsignature $true
}
#disconnect O365 connection
get-PSSession | remove-PSSession
set-mailboxmessageconfiguration -identity $user_name -signaturehtml (get-content $filename) -autoaddsignature $true