如何使用PowerShell从User Profile Service应用程序中的所有用户检索特定的用户属性?

问题描述 投票:0回答:1

enter image description here

 Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
$count
#$farm = Get-SPFarm
$siteList = Get-SPSite -Limit 1
$serviceContext = Get-SPServiceContext($siteList[0])
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($servicecontext)
$profiles = $profileManager.GetEnumerator()
foreach ($hi in $profiles) {
    if([string]::IsNullOrEmpty($hi["AboutMe"].Value) -eq $false){
        write-host "Acount Name:"$hi.AccountName"|AboutMe:"$hi["AboutMe"].Value
        $count++
    }
}
write-host $count

此代码不起作用,因为我不知道如何将C#的顶部转换为powershell

powershell sharepoint azure-ad-graph-api powershell-ise
1个回答
0
投票
以下PowerShell供您参考。

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue $count $siteList = Get-SPSite -Limit 1 $serviceContext = Get-SPServiceContext($siteList[0]) $profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext) $profiles = $profileManager.GetEnumerator() foreach ($profile in $profiles) { if([string]::IsNullOrEmpty($profile["AboutMe"].Value) -eq $false){ write-host "Acount Name:"$profile.AccountName"|AboutMe:"$profile["AboutMe"].Value $count++ } } write-host $count

enter image description here
© www.soinside.com 2019 - 2024. All rights reserved.