记录一个用PowerShell来获得UserProfile的某个属性的脚本

脚本如下:

Clear-Host

Add-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction "SilentlyContinue"

$url = "http://sps2010/"

$site = Get-SPSite $url

$context = Get-SPServiceContext $site

$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context)

$profiles = $profileManager.GetEnumerator()

while ($profiles.MoveNext()) {

  $userProfile = $profiles.Current

  $name = $userProfile.DisplayName

  if($name -eq "Yunlong Zhang")

  {

    $phone = $userProfile["WorkPhone"]

    $SipAddress = $userProfile["SPS-SipAddress"]

    Write-Host $name

    Write-Host $phone

    Write-Host $SipAddress

  }

}

My test result.

image

In SharePoint, we can see this value is displayed below.

clip_image003

 

参考资料

====================

Default user profile properties (SharePoint Server 2010)

http://technet.microsoft.com/en-us/library/hh147513.aspx

Access User Profile Properties from Powershell

http://sharepointkunskap.wordpress.com/2012/04/04/access-user-profile-properties-from-powershell/

posted on 2012-09-19 14:47  中道学友  阅读(922)  评论(0编辑  收藏  举报

导航

技术追求准确,态度积极向上