我是使用Microsoft人员的新手,我想使用powerdshell为Exchange上的所有在线用户(管理员用户而非管理员用户)设置一个Signatur,
例如,为了将用户从Active Directory引入,我们可以在powershell中使用此语句:
$ AD_User = Get-ADUser $ UserName-属性城市,公司,说明,街道地址
但是我们如何从Exchange Online或Azure(不是Active Directory)中获取用户列表但我想使Exchange的所有用户列表联机,然后对每个用户进行仇敌,我需要他的属性。
希望您能帮助我
下面是我用Ben Norcutt编写的PowerShell。
第1部分:创建签名文件以供以后推送到Office 365
# https://4sysops.com/archives/add-a-signature-to-office-365-emails-with-powershell/
#import the active directory module which is needed for Get-ADUser
import-module activedirectory
#set folder location for files, the folder must already exist
$save_location = 'c:\file_location\'
#$users = Get-ADUser -filter * -searchbase "OU=Testing,OU=Staff,OU=Test Users,DC=bigcheese,DC=com" -Properties * -Credential bigcheese\admin -Server bigcheese.com
$users = Get-ADUser -filter * -searchbase "OU=Testing,OU=Staff,OU=Test Users,DC=bigcheese,DC=com" -Properties *
foreach ($user in $users) {
$full_name = “$($user.GivenName) $($User.Surname)”
$account_name = "$($User.sAMAccountName)"
$job_title = "$($User.title)"
$location = "$($User.office)"
$dept = "$($User.department)"
$comp = "$($User.company)"
$email = "$($User.emailaddress)"
$phone = "$($User.telephoneNumber)"
$logo = "$($User.wWWHomePage)"
#We need to construct and write the html signature file
$output_file = $save_location + $account_name + ".htm"
Write-Host "Now attempting to create signature html file for " $full_name
"<span style=`"font-family: calibri,sans-serif;`"><strong>" + $full_name + "</strong><br />", $job_title + " - " + $location + "<br />", $dept + "<br />", $comp + "<br />", $phone + "<br />", "</span><br />", "<img alt=`"corporate logo`" border=`"0`" height=`"90`" src=`"" + $logo + "`" width=`"385`" />" | Out-File $output_file
}
第2部分:将签名文件推送到Office 365
#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