Quantcast
Channel: SharePoint Escalation Services Team Blog
Viewing all articles
Browse latest Browse all 170

PowerShell script to list all User Profiles in an SSP

$
0
0

Moved from http://blogs.msdn.com/vijgang

I had few thousand user profiles in my SharePoint 2007 SSP and needed to delete them. So here is a script that lists all the user profiles in an SSP. If you need to remove the user profiles, then just use the UserProfileManager.RemoveUserProfile method and pass it the UserProfile.Id property.

###################################################################################################

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.Office.Server.UserProfiles")

###########################
# "PUT THE SSP NAME HERE"
$SSPName = "SharedServices1"
###########################
$ServerContext = [Microsoft.Office.Server.ServerContext]::GetContext($SSPName)
$UPManager = new-object Microsoft.Office.Server.UserProfiles.UserProfileManager($ServerContext);
$enumProfiles = $UPManager.GetEnumerator();
"Total User Profiles available:" + $UPManager.Count
$count=0;
foreach ($oUser in $enumProfiles)
{
    $count = $count + 1;
    "(" + $count + ") " + $oUser.Item("PreferredName");
}

###################################################################################################

Disclaimer: The above code is provided "As Is". This is just a sample code and is not production ready.


Viewing all articles
Browse latest Browse all 170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>