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
我在foreachloop中不断收到错误,以下错误。当我输入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
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