记录一个用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/

原文地址:https://www.cnblogs.com/awpatp/p/2693673.html