Create User Profile Section in SharePoint 2010
We can to create new custom section for User Profile 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 Section link to create a new section for user profiles.

Automation: Create User Profile Section in SharePoint 2010 using
PowerShell
Here we will be seeing how to create new section for User Profile
in SharePoint 2010 using PowerShell.
Steps Involved:
-
Create the input XML file which contains the inputs for creating User Profile Section.
-
Create ps1 file which contains the script for creating User Profile Section.
CreateUserProfileSection.xml
<?xml
version="1.0"
encoding="utf-8"
?>
<UserProfileSection>
<SiteURL>http://serverName:8080/</SiteURL>
<Section
Name="CustomSection11"
DisplayName="CustomSection11"
></Section>
<Section
Name="CustomSection22"
DisplayName="CustomSection22"
></Section>
<Section
Name="CustomSection33"
DisplayName="CustomSection33"
></Section>
<Section
Name="CustomSection44"
DisplayName="CustomSection44"
></Section>
</UserProfileSection>
CreateUserProfileSection.ps1
#----------------Get the xml file---------------------------------------------------------------
[xml]$xmlData=Get-Content
"C:\Users\Desktop\ContentSources\CreateUserProfileSection.xml"
#----------------Create
new custom User Profile section---------------------------------------------
function
CreateUserProfileSection()
{
$site
=
Get-SPSite
$xmlData.UserProfileSection.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.UserProfileSection.Section
|
ForEach-Object{
$property
=
$pspm.GetSectionByName($_.Name)
if($property
-eq
$null)
{
$Privacy=$_.Privacy
$PrivacyPolicy=$_.PrivacyPolicy
$coreProp
=
$cpm.Create($true)
$coreProp.Name
=
$_.Name
$coreProp.DisplayName
=
$_.DisplayName
$cpm.Add($coreProp)
write-host
-f
green
$_.Name
section
is
created
successfully
}
else
{
write-host
-f
yellow
$_.Name
section
already
exists
}
}
}
#----------------Calling the
function---------------------------------------------
CreateUserProfileSection
Run the Script:
-
Go to Start.
-
Click on All Programs.
-
Click on Microsoft SharePoint 2010 Products and then click on SharePoint 2010 Management Shell.
-
Run the C:\Users\Desktop\ContentSources\CreateUserProfileSection.ps1
Output:![]()
And in the Central Administration you could see the newly created
custom sections for user profiles.

vinod vulisePosted Oct 6, 2011, 2:44 PM
Hi anand, How to create user profile with all properties in it using powershell scripting in sp2010...please help me out... Thanks in advance
vinod vulisePosted Oct 6, 2011, 2:42 PM
Hi anand i tried to run the scroipt nbut im getting an errors like "You cannot call a method on a null-valued expression." [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Sharepoint") [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles") [xml]$xmlData = Get-Content "C:\xmlsample.xml" function CreateUserProfileSection() { $SiteUrl = "url" $site = Get-SPSite $xmlData.UserProfileSection.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.UserProfileSection.Section | ForEach-Object{ $property = $pspm.GetSectionByName($_.Name) if($property -eq $null) { $Privacy=$_.Privacy $PrivacyPolicy=$_.PrivacyPolicy $coreProp = $cpm.Create($true) $coreProp.Name = $_.Name $coreProp.DisplayName = $_.DisplayName $cpm.Add($coreProp) write-host -f green $_.Name section is created successfully } else { write-host -f yellow $_.Name section already exists } } } CreateUserProfileSection
Stephen JohnsonPosted Sep 14, 2011, 12:45 AM
Hi what is the use of $upcm here.