查看访问过sharepoint site Search-UnifiedAuditLog的用户

时间:2017-11-10 20:41:02

标签: sharepoint office365 sharepoint-online

我尝试导出访问过我的集合中不同sharepoint网站的用户列表。我已经尝试过,我可以让它与内部用户合作,但不能用于外部用户。

$startdate = "11/10/2017 8:00 AM"
$enddate = "11/10/2017 9:00 AM"
$userIDs = (import-csv C:\Junk\User.csv).Email
foreach ($userid in $userids) {
    $AuditlogMain = Search-UnifiedAuditLog -StartDate $startdate -EndDate $enddate -RecordType SharePoint -Operations PageViewed -UserIds $userID -ObjectIds "https://sitename.sharepoint.com/" -Formatted
    $AuditlogMain.UserIDs | Select-object -Unique | Out-File C:\junk\Main.csv -Append
}

然后我获得了一个独特用户列表,但我想列出所有外部用户,我也不知道如何简单地更改来自" @。com"到_.com#EXT#@。onmicrosoft.com

或者是否有更简单的方法来导出访问过网站的用户? 如果你查看$AuditlogMain.AuditData,我想要更多信息,但我不知道如何提取它。因此,如果有人可以帮助我与外部用户联系,或者更有利的是帮助我从ClientIP, ObjectId, UserId中提取$AuditlogMain.AuditData,这将有所帮助。

提前致谢

1 个答案:

答案 0 :(得分:0)

摘自提供的文章:

$cred = Get-Credential

$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $session
Connect-MsolService -Credential $cred

$extUsers = Get-MsolUser | Where-Object {$_.UserPrincipalName -like "*#EXT#*" }

$extUsers | ForEach {
    $auditEventsForUser = Search-UnifiedAuditLog -EndDate $((Get-Date)) -StartDate $((Get-Date).AddDays(-7)) -UserIds $_.UserPrincipalName

    Write-Host "Events for" $_.DisplayName "created at" $_.WhenCreated

    $auditEventsForUser | FT
}

Remove-PSSession $session

这是一篇解释如何获取外部用户审核信息的文章: https://www.sharepointappie.nl/using-powershell-to-get-audit-data-for-external-users/

相关问题