首页 > 其他分享 >SharePoint Online 获取Audit Log

SharePoint Online 获取Audit Log

时间:2023-03-16 22:56:22浏览次数:35  
标签:Audit Log Get Exchange SharePoint PSSession AuditData Online

  前言

  我们在使用SharePoint Online的时候,经常有用户希望获取Audit Log。

  正文

  我们都知道,SharePoint Online的Audit Log都保存在管理中心,这里,我就从网上找到一段PowerShell获取,大家可以参考

Get-PSSession | Where-Object { $_.ConfigurationName -eq 'Microsoft.Exchange' } | Remove-PSSession -ErrorAction SilentlyContinue
$UserCredential = Get-Credential

# Create the session to Exchange Online
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -Uri https://outlook.office365.com/powershell-liveid/  -Credential $UserCredential -Authentication Basic -AllowRedirection

# Import the Exchange Online commands
Import-PSSession $Session
$csvFile = "D:\auditlog.csv"

# Setup our start and end dates to pull back events
$end = Get-Date
$start = $end.AddDays(-90)
$i = 1;
$startTime = Get-Date

do
{
    $AuditData = Search-UnifiedAuditLog -StartDate $start -EndDate $end -RecordType SharePointFileOperation -ResultSize 5000 -SessionCommand ReturnLargeSet -SessionId "ExtractLogs" -SiteIds "19739e8e-c67c-452b-bc77-9d62dd3e1b6d"
    $ConvertedOutput = $AuditData | Select-Object -ExpandProperty AuditData | ConvertFrom-Json
    $ConvertedOutput | SELECT CreationTime,UserId,Operation,Workload,ObjectID,SiteUrl,SourceFileName,ClientIP,UserAgent | Export-csv $csvFile -NoTypeInformation -Append -Force 
    Write-Host $i++ . $AuditData.Count
    $i = $i + 1;
}
Until($AuditData.Count -eq 0)

$endTime = Get-Date
Write-Host $startTime - $endTime

  特别的 

  Get-Credential是通过打开浏览器,输入账号密码的方式进行认证的,这个认证方式其实多种多样,也有后台写死用户名密码的方式,或者通过pfx秘钥的方式,大家有需要也可以去找一找相关文档。

标签:Audit,Log,Get,Exchange,SharePoint,PSSession,AuditData,Online
From: https://www.cnblogs.com/jianyus/p/17222436.html

相关文章

  • SharePoint Online 开启访问权限申请
    前言最近的项目,用户访问我们的站点,总提示没有权限,用户就问能不能自助申请权限访问?没问题,安排!正文1.我们进入网站设置-网站集管理员页面,如下图:......
  • SharePoint Online Hub Site
    前言最近发现SharePointOnline站点一个好玩的功能,叫做HubSite。正文1.我们先看一下效果,正常SharePoint站点的导航是蓝色下划线的,但是,站点还可以有一......
  • cnblogs 博客园自定义样式
    在博客园搜索资料时,发现很多博友的园子装饰的非常炫酷。想着也装饰一下自己的园子,搜索后发现一个不错的插件,记录一下。使用、配置教程:https://bndong.github.io/Cnblog......
  • ignite系列之14--log4j2日志配置
    Ignite支持各种常见的日志库和框架:JUL(默认);Log4j2;JCL;SLF4J。ignite默认日志介绍(无需配置)见:https://www.cnblogs.com/yangh2016/p/17221433.html但上述日志方式在......
  • docker login "Password change required but no TTY available."
    docker login"PasswordchangerequiredbutnoTTYavailable."报错现象 原因原因为账号密码过期或登录方式不支持解决方式一sudodockerlogin-uuser-px......
  • Automation 结合Logic Apps触发告警 - 配置
    创建好LogicApps之后,我们来看看如何实现automation以及logicapps的联动首先先配置logicapps,先设置好触发器,我们这里用HTTP的触发器然后设计好body的结构,主要就需要邮件的......
  • Thinkful - Logic Drills: Traffic light
    DESCRIPTIONYou'rewritingcodetocontrolyourtown'strafficlights.Youneedafunctiontohandleeachchangefromgreen,toyellow,tored,andthentogre......
  • MySQL三大日志——binlog、redo log和undo log详解
              ......
  • 重构:banner 中 logo 聚合分散动画
    1.效果展示在线查看2.开始前说明效果实现参考源码:Logo聚集与散开原效果代码基于reactjsx类组件实现。依赖旧,代码冗余。我将基于此进行重构,重构目标:基于最新......
  • 【漏洞复现】Fantastic Blog CMS SQL注入漏洞(CVE-2022-28512)
    FantasticBlogCMSSQL注入漏洞(CVE-2022-28512)0x01靶场介绍FantasticBlog(CMS)是一个绝对出色的博客/文章网络内容管理系统。它使您可以轻松地管理您的网站或博客......