Create User Profile Properties in SharePoint 2010 User Profile properties are used to describe personal information about the user. The IsMultiValued parameter in the object model indicates whether the property is a multivalue property or not. However, just like the property data type, this parameter is not modifiable, once it is set. We can to create User Profile MultiValue Properties in SharePoint 2010 from Central Administration. Go to Central Administration - Application Management - Manage Service Applications - User Profile Service Application. Click on Manage User Properties Click on New Property link to create a new custom user profile property. Multivalue Separator: Note: For more information on Multivalue Separator please refer http://msdn.microsoft.com/en-us/library/microsoft.office.server.userprofiles.multivalueseparator.aspx. Automation: Create User Profile Multivalue Properties in SharePoint 2010 using PowerShell Here we will be seeing how to create the User Profile Multivalue Properties in SharePoint 2010 using PowerShell. Steps Involved:
CreateUserProfileMultivalueProperties.xml <?xml version="1.0" encoding="utf-8" ?> <UserProfileMultivalueProperties> <SiteURL>http://serverName:8080/</SiteURL> <Property Name="CustomMultivalue1" DisplayName="CustomMultivalue1" Length="25" Privacy="Contacts" PrivacyPolicy="mandatory" IsVisibleOnEditor="$true" IsVisibleOnViewer="$true" IsMultivalued="$true" Separator="Comma"></Property> <Property Name="CustomMultivalue2" DisplayName="CustomMultivalue2" Length="25" Privacy="Contacts" PrivacyPolicy="mandatory" IsVisibleOnEditor="$true" IsVisibleOnViewer="$true" IsMultivalued="$true" Separator="Comma"></Property> <Property Name="CustomMultivalue3" DisplayName="CustomMultivalue3" Length="25" Privacy="Contacts" PrivacyPolicy="mandatory" IsVisibleOnEditor="$true" IsVisibleOnViewer="$true" IsMultivalued="$true" Separator="Comma"></Property> <Property Name="CustomMultivalue4" DisplayName="CustomMultivalue4" Length="25" Privacy="Contacts" PrivacyPolicy="mandatory" IsVisibleOnEditor="$true" IsVisibleOnViewer="$true" IsMultivalued="$true" Separator="Comma"></Property> </UserProfileMultivalueProperties> CreateUserProfileMultivalueProperties.ps1 #----------------Get the xml file--------------------------------------------------------------- [xml]$xmlData=Get-Content "C:\Users\Desktop\ContentSources\CreateUserProfileMultivalueProperties.xml" #----------------Create new custom User Profile Multivalue properties--------------------------------------------- function CreateUserProfileMultivalueProperties() { $site = Get-SPSite $xmlData.UserProfileMultivalueProperties.SiteURL $context = Get-SPServiceContext($site) $upcm = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($context); $ppm = $upcm.ProfilePropertyManager $cpm = $ppm.GetCoreProperties() $ptpm = $ppm.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User) $psm = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($context) $ps = $psm.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName [Microsoft.Office.Server.UserProfiles.ProfileType]::User)) $pspm = $ps.Properties $xmlData.UserProfileMultivalueProperties.Property | ForEach-Object{ $property = $pspm.GetPropertyByName($_.Name) if($property -eq $null) { $Privacy=$_.Privacy $PrivacyPolicy=$_.PrivacyPolicy $Separator=$_.Separator $coreProp = $cpm.Create($false) $coreProp.Name = $_.Name $coreProp.DisplayName = $_.DisplayName $coreProp.Type = [Microsoft.Office.Server.UserProfiles.PropertyDataType]::StringMultiValue $coreProp.Separator=[Microsoft.Office.Server.UserProfiles.MultiValueSeparator]::$Separator $coreProp.IsMultivalued=$_.IsMultivalued $coreProp.Length = $_.Length $cpm.Add($coreProp) $profileTypeProp = $ptpm.Create($coreProp); $profileTypeProp.IsVisibleOnEditor = $true; $profileTypeProp.IsVisibleOnViewer = $true; $ptpm.Add($profileTypeProp) $profileSubTypeProp = $pspm.Create($profileTypeProp); $profileSubTypeProp.DefaultPrivacy = [Microsoft.Office.Server.UserProfiles.Privacy]::$Privacy $profileSubTypeProp.PrivacyPolicy = [Microsoft.Office.Server.UserProfiles.PrivacyPolicy]::$PrivacyPolicy $pspm.Add($profileSubTypeProp) write-host -f green $_.Name multivalue property is created successfully } else { write-host -f green $_.Name multivalue property is created successfully } } } #----------------Calling the function--------------------------------------------- CreateUserProfileMultivalueProperties CreateUserProfileMultivalueProperties Run the Script:
Output: And in the Central Administration you could see the newly created custom multivalue properties in Custom properties section.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: