Showing posts with label User Profile. Show all posts
Showing posts with label User Profile. Show all posts

Thursday, August 23, 2012

Powershell exporting user profile information

Scenario:
I was asked by my client to export User Profile data into Excel.

Solution:
Answer was Powershell. I googled and found a good script to start with, I just added few more things and tested it. Here's the script

Code:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$siteUrl = "http://sp2010"
$outputFile = "C:\UserProfiles.csv"

$serviceContext = Get-SPServiceContext -Site $siteUrl
$profileManager = New-Object Microsoft.Office.Server.UserProfiles.UserProfileManager($serviceContext);
$profiles = $profileManager.GetEnumerator()

Write-Host "Exporting profiles" 

$collection = @()
foreach ($profile in $profiles) {
 
  $profileData = "" | select "AccountName","FirstName", "LastName","PreferredName","WorkPhone"
   $profileData.AccountName = $profile["AccountName"].Value
   $profileData.FirstName = $profile["FirstName"].Value
   $profileData.LastName = $profile["LastName"].Value
   $profileData.PreferredName = $profile["PreferredName"].Value
   $profileData.WorkPhone = $profile["WorkPhone"].Value
   $collection += $profileData
}

$collection | Export-Csv $outputFile -NoTypeInformation
Article:
User Profile export

Tuesday, January 12, 2010

SharePoint 2010 Tracking changes in profiles

Scenario:
There are lot of new features in SharePoint 2010 and among them one is Social Tagging.Also people like to track other colleagues. Here's a list of all the different activities you can subscribe for alerts as well as track.

Options:
c

Thursday, June 18, 2009

Programatically reading the My Links into datatable

Scenario:
Webpart to display all the my links

Solution:
Create a simple webpart


Code:

using System.Data;
using Microsoft.Office.Server;
using Microsoft.Office.Server.UserProfiles;
using Microsoft.SharePoint;

static DataTable GetQuickLinks(SPSite siteCollectionUrl, string loginName){
// string siteCollectionUrl = @"http://localhost";
// string loginName = @"domain\username";
var quickLinksTable ;

using (SPSite siteCollection = new SPSite(siteCollectionUrl))
{
using (SPWeb webSite = siteCollection.OpenWeb())
{
ServerContext serverContext = ServerContext.GetContext(siteCollection);
UserProfileManager userProfileManager = new UserProfileManager(serverContext);

if (userProfileManager.UserExists(loginName))
{
// Retreive the user profiles.
UserProfile userProfile = userProfileManager.GetUserProfile(loginName);

// Retreveing Quick Links Items from User Profile.
QuickLinkManager quickLinkManager = userProfile.QuickLinks;
QuickLink[] links = quickLinkManager.GetItems();

// Moving Items from Array of links to Data Table to bind with the Grid
quickLinksTable = new DataTable();

quickLinksTable.Columns.Add(new DataColumn("Title", typeof(System.String)));
quickLinksTable.Columns.Add(new DataColumn("Url", typeof(System.String)));

foreach (QuickLink oUserQuickLinks in links)
{
var rowLinks = quickLinksTable.NewRow();
rowLinks["Title"] = oUserQuickLinks.Title;
rowLinks["URL"] = oUserQuickLinks.Url;
quickLinksTable.Rows.Add(rowLinks);
}
}
}
}
return quickLinksTable;
}
Note:
Make sure you reference Microsoft.Office.Server.UserProfiles namespace and not Microsoft.SharePoint.Portal, as Microsoft.SharePoint.Portal is obsolete.
Article:
User Profile and Social Networking , User profile and web services
microsoft.office.server.userprofiles.quicklinkmanager
Follow me on Twitter

Sunday, March 15, 2009

What is MySites ?

A My Site is a Windows SharePoint Services site collection that provides a centralized location for each user to store and share his or her information—such as photos and documents—with other users, set user alerts, and connect with and track other colleagues throughout the organization. My Sites are created when a user clicks on the My Site link on the main page of an SharePoint Server 2007 site.

Users will feel more in control with the new privacy controls introduced in SharePoint Server 2007 My Sites and will be able to more granularly target their personal information. Custom roll-up Web Parts enable users to easily review their sites and documents,and link directly to that content. The ability to easily connect with other colleagues throughout the organization using specialized My Site colleague Web Parts allows knowledge to be more readily exchanged, enabling users to connect to colleagues with similar interests.

Its like companies' internal Facebook network, also MySites are only available to MOSS only

What is User Profile ?

A personal profile about each user includes properties such as a user’s title, e-mail, distri-bution list membership, and contact details. It is typically imported by SharePoint from a directory such as Active Directory, but it can also be manually created directly inside SharePoint. User profiles can be customized in SharePoint to include additional details, such as birthday and interests. Personal profile are used throughout SharePoint Server 2007 to disseminate or target information to users, help users locate colleagues with sim-ilar interests, and return search results on people.Its available for MOSS only.