Skip to content

Instantly share code, notes, and snippets.

@ciphertxt
Created March 26, 2013 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ciphertxt/5244834 to your computer and use it in GitHub Desktop.
Save ciphertxt/5244834 to your computer and use it in GitHub Desktop.
Creates a new user profile in the UPA
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