Created
March 26, 2013 11:50
-
-
Save ciphertxt/5244834 to your computer and use it in GitHub Desktop.
Creates a new user profile in the UPA
This file contains 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
Add-PSSnapin Microsoft.SharePoint.PowerShell | |
$siteUrl = "http://mycoolsite/" | |
$accountName = "MyAccountName" | |
$site = Get-SPSite $siteUrl | |
$context = Get-SPServiceContext($site) | |
$pm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($context) | |
# If user profile doesn't exist create new one | |
if ($pm.UserExists($accountName)) { | |
$userProfile = $pm.GetUserProfile($accountName) | |
} else { | |
$userProfile = $pm.CreateUserProfile($accountName) | |
} | |
# Update user profile properties | |
$userProfile["FirstName"].Value = "Bill" | |
$userProfile["LastName"].Value = "Gates" | |
# Commit changes | |
$userProfile.Commit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment