如何在SharePoint Online中获取用户配置文件?
SharePoint中的用户配置文件是存储有关用户信息的中央位置。它启用“我的网站”,社交功能并在租户中的多个网站之间共享配置文件。要在SharePoint Online中获取所有用户配置文件,请执行以下操作:
- 登录到SharePoint Online Admin >>单击左侧导航栏中的“更多功能” >>单击“用户配置文件”旁边的“打开”按钮。
- 在“用户个人资料”页面中,单击“人员”选项卡下的“管理用户个人资料”。使用搜索获取用户的用户资料。
此页面可帮助我们逐一获取各个用户的个人资料和属性。现在,让我们看看如何使用PowerShell在SharePoint Online中获取所有用户配置文件。
SharePoint Online:使用PowerShell获取所有用户配置文件
让我们使用PowerShell在SharePoint Online中获取所有用户配置文件
#Load SharePoint CSOM Assemblies Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.dll" Add-Type -Path "C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.Runtime.dll" Add-Type -Path "C:Program FilesCommon Filesmicrosoft sharedWeb Server Extensions16ISAPIMicrosoft.SharePoint.Client.UserProfiles.dll" #Variables $AdminSiteUrl = "https://crescent-admin.sharepoint.com" $CSVPath = "C:TempUserProfiles.csv" #Get Credentials $Cred = Get-Credential #Connect to AzureAD Connect-AzureAD -Credential $Cred #Get All Users from AzureAD $AllUsers = Get-AzureADUser -All:$True Write-host "Total Number of User Profiles Found:"$AllUsers.Count #Setup the context $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password) $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($AdminSiteURL) $Ctx.Credentials = $Credentials #Collect User data $PeopleManager = New-Object Microsoft.SharePoint.Client.UserProfiles.PeopleManager($Ctx) $UserDataCollection = @() $Counter = 1 ForEach($User in $AllUsers) { #Get User Profile $UserProfile = $PeopleManager.GetPropertiesFor(('i:0#.f|membership|'+$User.UserPrincipalName)) $Ctx.Load($UserProfile) $Ctx.ExecuteQuery() Write-Progress -Activity "Extracting User Profile Data..." -Status "Getting User Profile $Counter of $($AllUsers.Count)" -PercentComplete (($Counter / $AllUsers.Count) * 100) #Get User Profile Data $UserData = New-Object PSObject ForEach($Key in $UserProfile.UserProfileProperties.Keys) { $UserData | Add-Member NoteProperty $Key($UserProfile.UserProfileProperties[$Key]) } $UserDataCollection += $UserData $Counter++ } #Export Data to CSV File $UserDataCollection | Export-Csv -Path $CSVPath -NoTypeInformation
此PowerShell在SharePoint Online中获取所有用户配置文件和属性。