Second Life of a Hungarian SharePoint Geek

July 15, 2013

How to access creation information of specific SharePoint Group or User

Filed under: PowerShell, SP 2010 — Tags: , — Peter Holpar @ 21:43

Sometimes it is useful to know when a specific SharePoint group or user was created, and who has created it. Although the standard SharePoint objects (SPGroup / SPUser) does not contain this type of information, we can access it through the hidden user information list, where each of these objects are represented as simple list items.

The PowerShell scripts below provide examples how to access the information for a group:

$usersList = $site.RootWeb.SiteUserInfoList
$groupName = "MyGroup"
$groupId = $site.RootWeb.SiteGroups[$groupName].ID
$group = $usersList.GetItemById($groupId)
Write-Host Created by: $group["Author"]
Write-Host Created on: $group["Created"]
Write-Host Last modified by: $group["Editor"]
Write-Host Last modified on: $group["Modified"]

And for a specific user:

$usersList = $site.RootWeb.SiteUserInfoList
$loginName = "domain\user"
$userId = $site.RootWeb.AllUsers | ? { $_.UserLogin -eq $loginName } | % { $_.ID }
$user = $usersList.GetItemById($userId)
Write-Host Created by: $user["Author"]
Write-Host Created on: $user["Created"]
Write-Host Last modified by: $user["Editor"]
Write-Host Last modified on: $user["Modified"]

As you can see, I write out the editing information as well, but it is important to point out, that this data does not reflect modifications for example in group membership, only changed information in the list item, for example, renaming of a group or change e-mail address for a user.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: