审核连接到 Microsoft 365 的网络中Viva Engage用户

公司的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 中的“导出用户”函数创建输入文件。

  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 标识