ForEachL oop не работает в PowerShell, но у меня полный доступ, в чем проблема? - PullRequest
0 голосов
/ 13 февраля 2020

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

 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

Я продолжаю получать ошибки с foreachl oop, следующая ошибка. Когда я набираю SP-Farm, я получаю все обратно, чтобы не было проблем с доступом?

UserProfileDBCache_WCFLogging :: ProfileDBCacheServiceClient.GetUserData threw exception: Access is denied.
At line:8 char:10
+ foreach ($hi in $profiles) {
+          ~~~
    + CategoryInfo          : OperationStopped: (:) [], UserProfileApplicationNotAvailableException
    + FullyQualifiedErrorId : Microsoft.Office.Server.UserProfiles.UserProfileApplicationNotAvailableException

1 Ответ

0 голосов
/ 14 февраля 2020

Следующий 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

...