Friday, January 9, 2015

ProfileSubtypeProperty, CoreProperty, ProfileTypeProperty and syncConnection PropertyMapping

Some attributes belong to ProfileSubtypeProperty object, some belong to CoreProperty, and some belong to ProfileTypeProperty.

It would be nice to see which one belongs to which one.

Below is the script I built to help.

======== list user profile properties and syncConnection PropertyMapping ========

# https://gallery.technet.microsoft.com/office/SP2010-PowerShell-to-0fda04f7
# http://phadnisblog.com/2012/03/13/how-do-i-add-custom-user-profile-properties-with-powershell/
# http://sharepoint.stackexchange.com/questions/56972/delete-sharepoint-userprofile-property-using-powershell
# http://msdn.microsoft.com/en-us/library/office/ms496130(v=office.14).aspx
# http://blogs.msdn.com/b/chandru/archive/2011/09/17/powershell-script-to-create-a-new-user-profile-property.aspx
# http://sp2007hut.wordpress.com/2012/02/11/creating-sharepoint-2010-upa-properties-via-powershell/

cls

$connectionName="user profile sync connection Name"

function Get-SPServiceContext([Microsoft.SharePoint.Administration.SPServiceApplication] $profileApp)
{
    $profileApp = @(Get-SPServiceApplication | ? {$_.TypeName -eq "User Profile Service Application"})[0]
    return [Microsoft.SharePoint.SPServiceContext]::GetContext($profileApp.ServiceApplicationProxyGroup, [Microsoft.SharePoint.SPSiteSubscriptionIdentifier]::Default)
}

$serviceContext = Get-SPServiceContext
$userProfileConfigManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileConfigManager($serviceContext)

Write-Host "PropertyMapping, connectionName="$connectionName -ForegroundColor Yellow
$syncConnectionManager = $userProfileConfigManager.ConnectionManager[$connectionName]
$syncConnectionPropertyMapping = $syncConnectionManager.PropertyMapping
foreach ($itemPropertyMapping in $syncConnectionPropertyMapping.GetEnumerator())
{
    #if ($itemPropertyMapping.ProfileProperty.Name -NotMatch "SPS")
    #{
        #$itemPropertyMapping | fl *
        $itemPropertyMapping | select-object @{Name="Property Name"; Expression={$_.ProfileProperty.Name}}, DataSourcePropertyName, IsImport, IsExport
        break
    #}
}

$userProfilePropertyManager = $userProfileConfigManager.ProfilePropertyManager

$defaultSubType = [Microsoft.Office.Server.UserProfiles.ProfileSubtypeManager]::GetDefaultProfileName([Microsoft.Office.Server.UserProfiles.ProfileType]::User)

$coreProperties = $userProfilePropertyManager.GetCoreProperties()
Write-Host "coreProperties.Count="$coreProperties.Count -ForegroundColor Yellow

$userProfileTypeProperties = $userProfilePropertyManager.GetProfileTypeProperties([Microsoft.Office.Server.UserProfiles.ProfileType]::User)
$userProfileSubTypeManager = [Microsoft.Office.Server.UserProfiles.ProfileSubTypeManager]::Get($serviceContext)
$userProfileSubtype = $global:userProfileSubTypeManager.GetProfileSubtype($defaultSubType)

Write-Host "userProfileTypeProperties.Count="$userProfileTypeProperties.Count -ForegroundColor Yellow
Write-Host "userProfileSubtype.PropertiesWithSection.Count="$userProfileSubtype.PropertiesWithSection.Count -ForegroundColor Yellow
Write-Host "userProfileSubtype.Properties.Count="$userProfileSubtype.Properties.Count -ForegroundColor Yellow

Write-Host "Display first coreProperty" -ForegroundColor Green
foreach ($profileCoreProperty in $coreProperties)
{
    $profileCoreProperty | fl *
    break
}

foreach ($profileSubtypeProperty in $userProfileSubtype.Properties)
{
Write-Host "Display first SubtypeProperty" -ForegroundColor Green
    $profileSubtypeProperty | fl *
Write-Host "Display first TypeProperty" -ForegroundColor Green
    $profileSubtypeProperty.TypeProperty | fl *
    break
}

Write-Host "Display first coreProperty with no TypeProperty" -ForegroundColor Green
foreach ($profileCoreProperty in $coreProperties)
{
    $profileSubtypeProperty = $userProfileSubtype.Properties.GetPropertyByName($profileCoreProperty.Name)
    if ($profileSubtypeProperty -eq $null)
    {
        $profileCoreProperty | fl *
        break
    }
}





1 comment:

  1. Thank you your post allowed me to figure out why my workflow was crashing on a new site but fine on the other. The content type I was using with create task with content type was not being associated with the task list.

    ReplyDelete