Выгрузка подписи клиента Outlook локальных пользователей в Office 365 OWA (удаленно) - локальный обмен в Exchange в Интернете

Мы находимся в процессе миграции почтовых ящиков пользователей из локальной системы обмена в Office 365. Поскольку мы обслуживаем только несколько пользователей одновременно, наши требования заключались в том, чтобы синхронизировать подписи локальных клиентов Outlook с порталом Office 365 OWA. Таким образом, пользователь видит ту же подпись на своем портале OWA.

Кто-нибудь это делал?


person LT-    schedule 01.12.2017    source источник


Ответы (1)


Я понял это. Итак, я создал сценарий, чтобы помочь нашей команде миграции загрузить подпись клиента local outlook в Office 365.

Вам необходимо иметь доступ администратора к ПК пользователя и обмениваться правами администратора онлайн, такими как глобальный администратор.

Вот код:


write-host "`n`n`n`n"

#initializing variables
$username = $null
$computer = $null
$path = $null
$number = $null
$i = 0
$select = $null
$signs = $null
$chkerr = $false
$session = $null

#Run a continous loop
do {

    #if powershell is not connected to office 365 then run the connection code below
    if ($session.State -ne "opened") {

        Write-Host "`nChecking connection to Office 365: " -NoNewline
        Write-Host "Inactive!" -ForegroundColor white -BackgroundColor red

        Write-Host "`nConnecting to Office 365 account...`n"

        #Get user office 365 credentials 
        $UserCredential = Get-Credential

        #create session
        $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection

        #start the session to office 365
        Import-PSSession $Session
        Sleep 4
    }

    #if the session to 365 is success then run the code below
    if ($?) {
        Write-Host "`nChecking connection to Office 365: " -NoNewline
        Write-Host "Active!" -ForegroundColor Black -BackgroundColor green

        #Start a loop to prompt for username and machinename
        do {

            #this variable is used below and set as false if there is an error. Also, shows a message that user need to re-enter the information 
            $chkerr = $false
            if ($chkerr) {write-host "`nPlease try again..." -BackgroundColor yellow -ForegroundColor black}

            #store username and machine name
            $username = Read-Host "`n`nPlease enter user name"
            $computer = Read-Host "Please enter computer name"

            #if machine is not pingable then show an error
            if (!(Test-Connection $computer -Count 1) ) {Write-Host "`nError: Computer is offline or name is incorrect" -ForegroundColor white -BackgroundColor red; $chkerr = $true}
            else {
                #if machine is pingable then check if signature direcotry exists
                if (!(Test-Path "\\$computer\c$\Users\$username\AppData\Roaming\Microsoft\Signatures\")) { Write-Host "`nError: Outlook signature directory does not exists `nOR `nUsername is incorrect!" -ForegroundColor white -BackgroundColor red;$chkerr = $true}
            }

            #show error msg if username or machine name is left blank
            if ($username -eq $null -or !$username -or $computer -eq $null -OR !$computer) {Write-Host "`nError: Username or computer name cannot be left empty" -ForegroundColor white -BackgroundColor red;$chkerr = $true }


        #repeatedly ask for username and machine name until user gets it right or moves on to next username and machine name
        } while ($chkerr)

        #set the path to signature directory
        $path = "\\$computer\c$\Users\$username\AppData\Roaming\Microsoft\Signatures"

        #get a list of signature files and store them in a variable
        $number = Get-ChildItem "$path\*.htm" 

        #check if there are any signature files at all
        if ($number -or $number -ne $null) {

            #start a loop
            do { 

                #if there are multiple signature files found then show them on screen
                Write-Host "`nSelect one for following file:`n"
                for ([int]$i=0;$i -lt $number.count; $i++) {

                    Write-Host ("$i" +' --> ' + $number[$i].name)
                }

                #if there is more than one signature file then prompt user to select one
                if ($number.count -gt 1) {
                    $select = Read-Host "`nPlease enter your selection"

                    #show error if user enters a number that is of selection
                    if ([int]$select+1 -gt [int]$number.Count) {Write-Host "`nError: Please enter a valid selections!" -ForegroundColor white -BackgroundColor red}
                } else {

                    #if only one signature file is found then do not prompt and select that one file as default
                    $select = "0"
                    Write-Host "`nOnly one file found, selecting default file -->"  $number[$select].name -ForegroundColor black -BackgroundColor yellow
                }
            #repeat the loop until user selects atleast one signature file
            } while  ([int]$select+1 -gt [int]$number.Count)

            #show the selected signature file
            Write-Host "You have selected following signature file:" $number[$select].fullname
            sleep 3

            #grab the html file and store it into a variable
            Write-Host "`nImporting signatures into powershell"
            $signs = Get-Content $number[$select].fullname

            #show error if the signature import fails
            if (!$?) {Write-Host "`nError: Unable to import signature into powershell!" -ForegroundColor white -BackgroundColor red}
            else { 

                Write-Host "`nSuccess!" -ForegroundColor Black -BackgroundColor green
                Write-Host "`nImporting signatures to Office 365 account of $username"

                #import the signature into users OWA and set it to be used during replies, forwards and message creations.
                Get-Mailbox $username | Set-MailboxMessageConfiguration -SignatureHtml $signs -AutoAddSignature:$true -AutoAddSignatureOnReply:$true -AutoAddSignatureOnMobile:$true
                if (!$?) {Write-Host "`nError: Unable to import signature into Office 365 account!" -ForegroundColor white -BackgroundColor red}
                else {Write-Host "`nSuccess!" -ForegroundColor Black -BackgroundColor green}
            }
        }
        else {
            #show error if no signature files are found
            Write-Host "`nError: No signature files found!" -ForegroundColor white -BackgroundColor red
        }

    } 
    else {
        # show error if we are unable to connect to office 365 account.
        Write-Host "`nError: Connection to office 365 is required for this script to work" -ForegroundColor white -BackgroundColor red
    }

} while ($true)


Успешная проверка результатов:

Установление соединения:  введите описание изображения здесь

После успешного подключения:  введите описание изображения здесь

После ввода имени пользователя и пароля:  введите описание изображения здесь

После выбора:  введите описание изображения здесь

Представление OWA:  введите описание изображения здесь


Проверка ошибок при вводе данных пользователем:

Ввод неверных учетных данных Office 365:  введите описание изображения здесь

Ввод правильного имени компьютера, но неправильного имени пользователя:  введите описание изображения здесь

Ввод правильного имени пользователя, но неправильного имени компьютера:  введите описание изображения здесь

Ввод неправильного выбора, выходящего за рамки предоставленного набора параметров:  введите описание изображения здесь


Вы также можете изменить сценарий, чтобы получать ввод с листа Excel.

person LT-    schedule 01.12.2017