SharePoint Online: PowerShell'i kullanarak Değişiklik Günlüğünü Alın


SharePoint içerik veritabanında, site koleksiyonunda, sitede veya listede yapılan değişikliklerin bir listesini almak için SharePoint Online'da Değişiklik Günlüğünü sorgulayabiliriz. İşte PowerShell örneğim:

PowerShell, SharePoint Online'da Değişiklik Günlüğünü Alacak:

SharePoint Online değişiklik günlüğünü almak ve hangi değişikliklerin ne zaman yapıldığı da dahil olmak üzere listenizde veya kitaplığınızda yapılan tüm değişikliklerin bir listesini görüntülemek için bu komut dosyasını kullanabilirsiniz:


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Variables
$SiteURL="https://Crescent.sharepoint.com"
$ListName ="Documents"

#Setup Credentials to connect
$Cred= Get-Credential
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)

#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials

#Get the web
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()

#Get the List
$List = $Ctx.Web.Lists.GetByTitle($ListName)
$Ctx.Load($List)
$Ctx.ExecuteQuery()

#Getting changes in the Change Log
$ChangeQuery = New-Object Microsoft.SharePoint.Client.ChangeQuery($true,$true)
$ChangesCollection=$List.GetChanges($ChangeQuery)
$Ctx.Load($ChangesCollection)
$Ctx.ExecuteQuery()

#Get All Changes                
Write-Host "Number of Changes found:" $ChangesCollection.Count
$ChangesCollection | Select ChangeType, TypedObject, Time

Write-host "List Changes:"
#Iterate through the Changes Collection
ForEach($Change in $ChangesCollection)
{
    #Filter List Item changes
    If($Change -is [Microsoft.SharePoint.Client.ChangeItem])
    {
        $Change | Select ItemID, ChangeType, Time
    }
}

Komut dosyası sonucu:

İlgili makaleler