posts - 16 , comments - 4 , trackbacks - 0

create custom user profile property of type taxomomy multivalue

http://sharepoint-community.net/profiles/blogs/sp2013-powershell-create-userprofile-taxonomy-based-property -----------------------------------OR-------------------------------------------- param ( # Site Url input parameter [string]$SiteUrlParameter ) try { $propertyNames = New-Object System.Collections.ArrayList $propertyDisplayNames = New-Object System.Collections.ArrayList $termSetNames = New-Object System.Collections.ArrayList $siteUrl = "http://ABC:123" if($SiteUrlParameter -ne $null) { $siteUrl = $SiteUrlParameter } # Add your Custom User Properties to the Arraylist below #if you add term set name as NA, the correspoding property will be added as single line of text $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") $propertyNames.Add("UPS-ABC") $propertyDisplayNames.Add("ABC") $termSetNames.Add("ABC") if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" } [System.Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server") [System.Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") [System.Void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles.UserProfileManager") $site = Get-SPSite $siteUrl $serviceContext = Get-SPServiceContext $site $upConfigMgr = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext) $coreProperties = $upConfigMgr.ProfilePropertyManager.GetCoreProperties() $taxonomySession = Get-SPTaxonomySession -Site $site $loopcount = 0 foreach($propertyName in $propertyNames) { $propertyDisplayName = $propertyDisplayNames[$loopcount] $termSetName = $termSetNames[$loopcount] if($coreProperties.GetPropertyByName($propertyName) -ne $null) { Write-Host "Property Already exists, deleting" $propertyName $coreProperties.RemovePropertyByName($propertyName) } $upcoreproperty = $coreProperties.Create($false) $upcoreproperty.Name = $propertyName $upcoreproperty.DisplayName = $propertyDisplayName if($termSetName -ne "NA") { $upcoreproperty.Type = [Microsoft.Office.Server.UserProfiles.PropertyDataType]::StringMultiValue $upcoreproperty.IsMultivalued = $true $mytermSet = $taxonomySession.GetTermSets($termSetName,1033) $upcoreproperty.TermSet = $mytermSet[0] } else { $upcoreproperty.Type = [Microsoft.Office.Server.UserProfiles.PropertyDataType]::StringSingleValue $upcoreproperty.IsMultivalued = $false $upcoreproperty.Length = 100 } $upcoreproperty.Description = "This Property Value is populated by a Timer Job" $upcoreproperty.IsSearchable = $true $coreProperties.Add($upcoreproperty) $userProfilePropertyManager = $upConfigMgr.ProfilePropertyManager $userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User) $userProfileProperty = $userProfileTypeProperties.Create($upcoreproperty) $userProfileProperty.IsVisibleOnEditor = $false $userProfileProperty.IsVisibleOnViewer = $true $userProfileTypeProperties.Add($userProfileProperty) $upSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::Get($serviceContext) $userProfile = $upSubTypeManager.GetProfileSubtype([Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)) $userProfileProperties = $userProfile.Properties $userProfileSubProperty = $userProfileProperties.Create($userProfileProperty) $userProfileSubProperty.DefaultPrivacy = [Microsoft.Office.Server.UserProfiles.Privacy]::Public $userProfileSubProperty.PrivacyPolicy = [Microsoft.Office.Server.UserProfiles.PrivacyPolicy]::OptIn $userProfileSubProperty.IsUserEditable = $false $userProfileSubProperty.UserOverridePrivacy = $false $userProfileProperties.Add($userProfileSubProperty) $userProfileProperty.CoreProperty.Commit() $userProfileProperty.Commit() $userProfileSubProperty.Commit() Write-Host "Propert Created InternalName" $propertyName " Display Name " $propertyDisplayName " Mapped to Termset " $termSetName $loopcount = $loopcount+1 } } catch { Write-Error "Error Creating Profile properites, check error details." Write-Error $_.message }

Print | posted on Wednesday, July 8, 2015 6:14 AM | Filed Under [ taxonomy folksonomy CUSTOMUSERPROFILE USERPROFILE PROPERTY ]

Feedback

Gravatar

# re: create custom user profile property of type taxomomy multivalue

Now that you have a clear idea of what your theme is, you can flesh out
the beginning and the end. Try to stay away from cutesy or clever opening lines and instead, try to answer
PRIYAROMI
7/26/2017 2:59 AM | hppy romz
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 

Powered by: