Post

Get SharePoint profiles located in the Default User Profile Subtype
This PowerShell script will get SharePoint profiles located in the Default User Profile Subtype or any other Subtype under the User Profile Service Application. My colleague needed a script to list all profiles under the Default User Profile Subtype. You need to search the profile DB using the User Profile Service Application to find profiles […]

This PowerShell script will get SharePoint profiles located in the Default User Profile Subtype or any other Subtype under the User Profile Service Application. My colleague needed a script to list all profiles under the Default User Profile Subtype. You need to search the profile DB using the User Profile Service Application to find profiles but you can also list all the profiles with PowerShell. This script has been created for the Default User Profile Subtype but can also be used for any other Subtype.

image

First you will need to verify if you have the correct permissions to use the below script:

– Web Application admin on the web application hosting the My Site

– Full control permissions on the User Profile Service Application

– Administrator on the User Profile Service Application

You will receive the following errors if these permissions are not set:

New-Object : Exception calling “.ctor” with “1” argument(s): “No User Profile Application available to service the request. Contact your farm administrator.”

At line:35 char:19

+     $upm = new-object <<<<  Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)

    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException

    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

First you will need to run the SharePoint Management Shell as administrator

or

User Profile Application Proxy failed to retrieve partitions from Us er Profile Application: Microsoft.Office.Server.UserProfiles.UserPro fileApplicationNotAvailableException: No User Profile Application av ailable to service the request.

Then start the SharePoint Management Shell as administrator

image

Run the following commands where you will need to change the site url to match your My Site Host

$site = Get-SPSite -Identity "<My Site Host>"

#Get all profiles
$serviceContext = Get-SPServiceContext $site
$upm = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext)
$Profiles = $upm.GetEnumerator()
foreach($profile in $Profiles)
{
 if ($profile.profilesubtype.Displayname -eq "Default User Profile SubType")
 {
       $profile.displayname
 }
}

The output will be all the displaynames from profiles located in the Default User Profile Subtype

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Archive