2017-11-10 202 views
1

我試着導出誰訪問過我的集合中的不同SharePoint網站的用戶的列表,請參閱用戶。我已經試過,我可以得到它與內部用戶的工作,但不能外用。誰訪問SharePoint網站的搜索,UnifiedAuditLog

$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還有一些我想要的信息,但我不知道如何提取它。所以如果有人可以幫助我與外部用戶或更好地幫助我從$AuditlogMain.AuditData提取ClientIP, ObjectId, UserId這將是有益的。

由於從文章提前

回答

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/