Last active
June 12, 2018 17:04
-
-
Save vaderj/b0188a13e60cc6fc5354ec5c1b8ca3a4 to your computer and use it in GitHub Desktop.
Get User Profile mapped properties (BEYOND SPUser type)http://chuvash.eu/2012/04/04/access-user-profile-properties-from-powershell/http://spandps.com/2010/11/04/updating-user-profile-properties-via-powershell-pictureurlsharepoint-2010-in-sp2010/ #PowerShell #SharePoint
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Set up default variables | |
#My Site URL | |
$mySiteUrl = "http://mysite/" | |
#The part of the picture URL you are trying to find | |
$currentURLValue = "http://mypersonalsite" | |
#The value that will replace the above | |
$newURLValue = "http://mysite:80" | |
#The internal name for PictureURL | |
$upPictureURLAttribute = "PictureURL" | |
#Get site objects and connect to User Profile Manager service | |
$site = Get-SPSite $mySiteUrl | |
$context = Get-SPServiceContext $site | |
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) | |
$profiles = $profileManager.GetEnumerator() | |
foreach ($userProfile in $profiles) { | |
if ($userProfile[$upPictureURLAttribute] -ne '') { | |
$newPictureURL = $userProfile[$upPictureURLAttribute].toString() | |
$newPictureURL = $newPictureURL.Replace($currentURLValue, $newURLValue) | |
write-host "Before: " $userProfile[$upPictureURLAttribute].toString() " | After: " $newPictureURL | |
#Get user profile and change the value - uncomment the lines below to commit the changes | |
#$userProfile[$upPictureURLAttribute].Value = $newPictureURL | |
#$userProfile.Commit() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$url = "http://intranet/" | |
$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 | |
$phone = $userProfile["WorkPhone"] | |
$line = '{0};{1}' -f $name, $phone | |
write $line | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment