【问题标题】:Update custom user profile properties - Powershell - SharePoint更新自定义用户配置文件属性 - Powershell - SharePoint
【发布时间】:2015-02-18 15:11:53
【问题描述】:

更新自定义用户配置文件属性时出现问题。有同样问题的人,代码如下:

[void][reflection.assembly]::Loadwithpartialname("Microsoft.Office.Server");            
$site=new-object Microsoft.SharePoint.SPSite("$ProfilFullURL");            
$serviceContext = Get-SPServiceContext $site;            
$site.Dispose();            
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);

function Update-UserProfileProperty ($property, $excelProperty)
{
Write-Host "Setting property $property : " -NoNewline
Try
{       
    $userProfile["$property"].Value = $excelProperty;            
    $userProfile.Commit()
    Write-Host "$excelProperty" -ForegroundColor Green
}
Catch [system.exception]
{
    Write-Host "Error" -ForegroundColor Red
}
}

我要做的是将 excel 电子表格中的迁移数据添加到自定义用户配置文件属性中。用户和财产存在!

该代码适用于 FirstName 等标准属性。

【问题讨论】:

    标签: powershell sharepoint user-profile custom-properties


    【解决方案1】:

    跳出的一个项目是,您在代码有机会使用 SPSite 对象之前就将其处理掉了。移动'$site.Dispose(); ' 到代码块的末尾。

    【讨论】:

    • 该解决方案适用于标准用户配置文件属性,但不适用于自定义属性。所以我不认为 $site.Dispose() 是问题
    猜你喜欢
    • 2017-10-06
    • 1970-01-01
    • 1970-01-01
    • 2011-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-06-11
    相关资源
    最近更新 更多