【问题标题】:set signature to Exchange online users using powershell ,使用 powershell 为 Exchange 在线用户设置签名,
【发布时间】:2020-06-17 13:01:20
【问题描述】:

我是使用 Microsoft 员工的新手,我想使用 powerdshell 为 Exchange Online 上的所有用户(管理员而不是管理员用户)设置 Signatur,

例如,要从 Active Directory 中获取用户,我们可以在 powershell 中使用此语句:

$AD_User = Get-ADUser $UserName -Properties City, Company, Description, StreetAddress

但是我们如何从 Exchange Online 或 Azure(不是 Active Directory)中获取用户列表 但我想从 Exchange 在线获取所有用户的列表,然后针对每个用户,我需要他的属性。

希望你能帮到我

【问题讨论】:

    标签: powershell exchange-server


    【解决方案1】:

    下面是我使用的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
    

    【讨论】:

    • 你好,谢谢你的帮助,是的,万一我们在本地登录,然后我们可以在线推送签名,但万一员工不在公司,他直接想从网站上打开outlook,这种方式是不可能的。为此,我需要一个可以放入在线域中的脚本。例如,要使用 AD 的用户列表,我们可以使用 $users = Get-ADUser ,但我如何才能让所有用户不在线交流。
    • @Doaa - 您在一个问题中混合了多个问题。创建单独的问题,每个问题一项。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-03-03
    • 1970-01-01
    • 2021-03-23
    • 1970-01-01
    相关资源
    最近更新 更多