0

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

[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 等标准属性。

4

1 回答 1

1

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

于 2015-02-18T21:28:20.177 回答