稽核 Viva Engage 連線至 Microsoft 365 之網路中的使用者

貴公司的 Viva Engage 網路可能會有不再為貴公司工作的使用者。 或者,某些 Viva Engage 使用者可能因為沒有對應的 Microsoft 365 帳戶而使用其電子郵件和密碼登入。 若要分析這類情況並採取動作,您可以稽核 Viva Engage 使用者。 這包括導出 Viva Engage 使用者清單、使用適用於 Windows PowerShell 的 Azure Active Directory 模組在 Microsoft 365 中尋找這些 Viva Engage 用戶的狀態,以及分析結果並採取動作。

除了稽核 Viva Engage 使用者之外,您可能還想要深入瞭解如何從 Microsoft 365 順暢地管理 Viva Engage 服務。 如需詳細資訊,請參閱為 Viva Engage 用戶強制執行 Microsoft 365 身分識別

匯出 Viva Engage 用戶清單

您必須先建立包含要使用之腳本用戶帳戶清單的輸入檔,才能執行稽核腳本。 您可以使用 Viva Engage 中的 Export Users 函式來建立輸入檔。

  1. 在 Viva Engage 中,選取 Viva Engage 設定圖示 ,然後選取 [網络 管理員]

  2. 選取 [匯出使用者]

  3. 在 [匯出使用者] 頁面上,選擇 [ 匯出所有使用者],然後選取 [ 匯出]

  4. 儲存導出的檔案。 檔案會儲存為擴展名為 .zip 壓縮檔案。

  5. 移至您儲存壓縮檔的位置,然後解壓縮檔案。

注意事項

壓縮檔內包含數個檔案。 您只需要名為 users.csv 的檔案。

在 Microsoft 365 中尋找 Viva Engage 用戶的狀態

  1. 安裝和設定適用於 Windows PowerShell 的 Azure Active Directory 模組。 如需相關指示,請閱讀下列檔:Microsoft Entra ID 說明]

  2. 複製下列範例程式代碼,將它貼到 [記事本] 之類的文本編輯器中,然後將檔案儲存為 UserMatchToAzureAD.ps1

    請隨意修改,以符合貴組織的需求。

     <#Copyright 2016  Microsoft Licensed under the Apache License, Version 2.0 (the "License");  you may not use this file except in compliance with the License.  You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0  Unless required by applicable law or agreed to in writing, software  distributed under the License is distributed on an "AS IS" BASIS,  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the specific language governing permissions  and limitations under the License.  Viva Engage auditing tool for Office 365 looks for active Viva Engage accounts  that  are missing from Office 365 / Azure AD.  Takes User.csv file from Viva Engage Data Export as the input file.   Compares all Active Viva Engage accounts in the input file to user   lookup in Azure AD. User is searched by both email and proxyAddresses.   The output csv file is exactly matching the source file, but it includes  three new columns: exists_in_azure_ad, object_id and azure_licenses:  exists_in_azure_ad: Will be TRUE or FALSE, and signals that the user can be, or cannot be found in Office 365 / Azure AD  object_id: For users that can be found, lists the ObjectId in Azure AD  azure_licenses: For users that can be found, lists the plans assigned to the user in Azure AD. 
    
     azurepowershell
    
     This information can be used to double check licenses are assigned correctly for each user.  
    
     azurepowershell
    
     Params -  UseExistingConnection: Defines if the script should try to use an existing Azure AD connection. Will prompt for credentials and will start a new connection if $FALSE. Default is $FALSE  InputFile: Source CSV file of users, coming from the Viva Engage User Export tool  OutputFile: Output location to save the final CSV to  Example -  UserMatchToAzureAD.ps1 -InputFile .\Users.csv -OutputFile .\Results.csv  #> 
    
     azurepowershell
    
     Param(
     	 [bool]$UseExistingConnection = $FALSE,
     	 [string]$InputFile = ".\Users.csv",
     	 [string]$Outputfile = ".\Results.csv"
     	) 
       if(!$UseExistingConnection){
     	   Write-Host "Creating a new connection. Login with your Office 365 Global Admin Credentials..."
     	   $msolcred = get-credential
     	   connect-msolservice -credential $msolcred
        }
        Write-Host "Loading all Office 365 users from Azure AD. This can take a while depending on the number of users..."
        $o365usershash = @{}
        get-msoluser -All | Select userprincipalname,proxyaddresses,objectid,@{Name="licenses";Expression={$_.Licenses.AccountplanId}} | ForEach-Object {
     	   $o365usershash.Add($_.userprincipalname.ToUpperInvariant(), $_)
     	   $_.proxyaddresses | ForEach-Object {
     		   $email = ($_.ToUpperInvariant() -Replace "SMTP:(\\*)*", "").Trim()
     		   if(!$o365usershash.Contains($email))
     		   {
     			   $o365usershash.Add($email, $_)
     		   }
     	   }
        }
        Write-Host "Matching Viva Engage users to Office 365 users"
        $yammerusers = Import-Csv -Path $InputFile | Where-Object {$_.state -eq "active"}
        $yammerusers | ForEach-Object {
     	   $o365user = $o365usershash[$_.email.ToUpperInvariant()]
     	   $exists_in_azure_ad = ($o365user -ne $Null)
     	   $objectid = if($exists_in_azure_ad) { $o365user.objectid } else { "" }
     	   $licenses = if($exists_in_azure_ad) { $o365user.licenses } else { "" }
     	   $_ | Add-Member -MemberType NoteProperty -Name "exists_in_azure_ad" -Value $exists_in_azure_ad
     	   $_ | Add-Member -MemberType NoteProperty -Name "azure_object_id" -Value $objectid
     	   $_ | Add-Member -MemberType NoteProperty -Name "azure_licenses" -Value $licenses
        } 
       Write-Host "Writing the output csv file..."
       $yammerusers | Export-Csv $Outputfile -NoTypeInformation 
       Write-Host "Done." 
    
  3. 從適用於 Windows PowerShell 命令視窗的 Azure Active Directory 模組中,執行 命令,如下列範例所示,傳遞從 Viva Engage 導出的輸入檔和輸出檔案位置。

    範例使用方式:

     UserMatchToAzureAD.ps1 -InputFile .\Users.csv -OutputFile .\Results.csv
    

    如需如何執行腳本的詳細資訊,請參閱上述的 PS1 檔案。

分析結果並採取動作

  1. 開啟結果 CSV 檔案,並篩選掉顯示 exists_in_azure_ad 數據行為 FALSE 的所有數據列。

    每個帳戶都是存在於 Viva Engage 中的帳戶,但不在 Microsoft 365 / Microsoft Entra ID 中。 針對每個項目,決定您是否需要:

    • 如果使用者不應該有存取權,請在 Viva Engage 中暫停用戶帳戶。

    • 在 Microsoft 365 / Microsoft Entra ID 中建立使用者。

  2. 完成這些作業之後,建議您從一開始就再次執行這些步驟,以確認所有用戶現在都已在 Microsoft Entra ID 中找到。

在完整稽核之後,如果您要強制執行 Microsoft 365 身分識別,請考慮註銷所有目前的使用者,以確保每個人都現在使用其 Microsoft 365 認證登入,而不是使用快取的認證。 如果您選擇這樣做,請務必先與您的用戶通訊。 針對 Viva Engage 用戶強制執行 Microsoft 365 身分識別中的詳細資訊。