Domanda

I want to get the details (date/time) of when a particular user added to the particular SharePoint group. Can anyone help

È stato utile?

Soluzione

If you have enabled Audit log in your server, then it is possible using powershell script,

$site = Get-SPSite "http://yoursite.company.com"

$startDate = Get-Date "1/21/2020 9:00 AM" 
$loginName = "domain\user" 
$userId = $site.RootWeb.AllUsers | ? { $_.UserLogin -eq $loginName } | % { $_.ID }

function DumpEvents($site, $searchPattern, $startDate, $eventType, $eventName) {  
  $usersList = $site.RootWeb.SiteUserInfoList  

  $query = New-Object Microsoft.SharePoint.SPAuditQuery($site) 
  $query.AddEventRestriction($eventType) 
  $query.SetRangeStart($startDate) 
  $result = $site.Audit.GetEntries($query) | ? { $_.EventData -like $searchPattern }     | % { 
   [xml]$eventData = "<eventData>" + $_.EventData + "</eventData>" 
   $groupId = $eventData.SelectSingleNode("//groupid").InnerText  
   $groupName = $groupId  
   try { $groupName = $usersList.GetItemById($groupId).Name } catch { } 
   $userName = $_.UserId 
   try { $userName  = $usersList.GetItemById($_.UserId)["Name"] } catch { } 
   Write-Host $eventName "Group" $groupName "on" $_.Occurred "by" $userName 
  } 
}

Write-Host Changes in group membership of $loginName since $startDate 
Write-Host ————————————————–

$searchPattern = "*<user>$userId</user>*" 
$eventType = [Microsoft.SharePoint.SPAuditEventType]::SecGroupMemberDel 
DumpEvents $site $searchPattern $startDate $eventType "Deleted from"

Write-Host ————————————————–

$searchPattern = "*<userId>$userId</userId>*" 
$eventType = [Microsoft.SharePoint.SPAuditEventType]::SecGroupMemberAdd 
DumpEvents $site $searchPattern $startDate $eventType "Added to"

SOURCE

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top