SharePoint Online: Son Değiştirilme Tarihine Göre Kullanılmayan Tüm Siteleri Bulun
Gereksinim: Son değiştirilme tarihine göre kullanılmayan tüm SharePoint Çevrimiçi Sitelerini alın.
SharePoint Çevrimiçi Site Koleksiyonlarının Son Değiştirilme Tarihini Nasıl Bulabilirsiniz?
Çoğu SharePoint yöneticisi gibiyseniz, SharePoint Online kiracınızda artık kullanılmayan çok sayıda siteniz varsa performansı optimize etmek ve SharePoint ortamınızı düzenli tutmak için site koleksiyonlarınızı temizlemek isteyebilirsiniz. Kullanılmayan siteleri silmek manuel bir işlem olabilir ancak bunları bulmanın kolay bir yolu vardır. Kriter olarak son değiştirilme tarihini kullanarak, bir süredir kullanılmayan siteleri kolayca bulabilirsiniz. Bu blog gönderisi, kullanılmayan SharePoint Online sitelerini bulmak için PowerShell'i nasıl kullanacağınızı gösterecektir.
Modern SharePoint Çevrimiçi Yönetim merkezi, liste öğelerinin veya dosyaların sitede görüntülendiği/düzenlendiği/paylaşıldığı tarihin değerini sağlayan "Son Etkinlik (UTC)" sütununun yanı sıra, kiracıdaki tüm sitelerin düzenli bir görünümünü sunar.
PowerShell, SharePoint Online'da Kullanılmayan Siteleri Buluyor
PowerShell kullanarak herhangi bir SharePoint Online sitesinin değiştirilme tarihini almaya ne dersiniz? Arşivleme veya silme gibi başka işlemler yapmadan önce sitelerinizin güncel olduğundan emin olmak için sitelerinizi denetliyorsanız bu kullanışlıdır. PowerShell kullanarak belirli bir sitenin Son Değiştirilme Tarihi değerini bulalım.
#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/sites/marketing"
Try {
#Setup Credentials to connect
$Cred= Get-Credential
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the Web
$Web = $Ctx.web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Get the last modified date of the web
Write-host "Last Modified:"$Web.LastItemUserModifiedDate
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
Verilen site koleksiyonunun tüm alt sitelerinin son değiştirilme tarihi değerini almak için bu komut dosyasını biraz değiştirelim.
#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/sites/marketing"
#Get Credentials to connect
$Cred= Get-Credential
Function Get-SPOSiteLastModified($SiteURL)
{
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the site
$Web = $Ctx.web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Get the last modified date of the site
Write-host "Last Modified Date of $($SiteURL):"$Web.LastItemUserModifiedDate
#Get Subsites of the site
$Webs = $Web.Webs
$Ctx.Load($Webs)
$Ctx.ExecuteQuery()
ForEach($SubWeb in $Webs)
{
#Call the function to get subsite's last modified date
Get-SPOSiteLastModified $SubWeb.URL
}
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
}
#Call the function to get last modified date of a site and its subsites
Get-SPOSiteLastModified $SiteURL
PowerShell'i kullanarak Etkin Olmayan SharePoint Çevrimiçi Sitelerini edinin
Kiracıda etkin olmayan SharePoint site koleksiyonlarını bulmaya ne dersiniz?
#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
$AdminSiteURL ="https://crescent-admin.sharepoint.com"
$CSVFile = "C:\Temp\SiteData.csv"
#Get Credentials to connect
$Cred= Get-Credential
#Connect to Admin Center
Connect-SPOService -Url $AdminSiteURL -Credential $Cred
#Get All Site Collections
$Sites = Get-SPOSite -Limit All
$SiteData = @()
#Loop through each site collection
ForEach($Site in $Sites)
{
Write-host -f Yellow "Getting Data for Site:" $Site.URL
Try {
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Site.URL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get the Root Web
$Web = $Ctx.web
$Ctx.Load($Web)
$Ctx.ExecuteQuery()
#Get the last modified date of the site
$SiteData += New-Object PSObject -Property @{
SiteTitle = $Web.Title
URL = $Web.Url
LastModified= $Web.LastItemUserModifiedDate
}
}
Catch {
write-host -f Red "Error:" $_.Exception.Message
}
}
#Export the results to CSV
$SiteData | Export-CSV $CSVFile -NoTypeInformation
İşte SharePoint Online etkin olmayan siteler raporu:
PnP PowerShell, Son 30 Gün İçinde Kullanılmayan Site Koleksiyonlarını Alacak
Site koleksiyonu düzeyinde “LastContentModifiedDate” özelliğine sahibiz. SharePoint Online'da değiştirilen tarihi almak için PnP PowerShell'i kullanalım.
$TenantAdminURL = "https://Crescent-Admin.SharePoint.com"
$TenantURL = "https://Crescent.SharePoint.com"
$DaysInActive = 30 # number of days to check since last modified
$CSVPath = "C:\Temp\InactiveSites.csv"
#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
#Get All Site collections - Exclude BOT, Video Portals and MySites
$SiteCollections = Get-PnPTenantSite -Filter "Url -like $TenantURL -and Url -notlike '-my.sharepoint.com/' -and Url -notlike '/portals/'"
#Calculate the Date
$Date = (Get-Date).AddDays(-$DaysInActive).ToString("MM/dd/yyyy")
#Get All Site collections where the content modified
$InActiveSites = $SiteCollections | Where {$_.LastContentModifiedDate -le $Date} | Select Title, Url, LastContentModifiedDate, Template, StorageMaximumLevel
#Export to CSV
$InActiveSites
$InActiveSites | Export-Csv -Path $CSVPath -NoTypeInformation
Sonraki adım? Kullanılmayan SharePoint Online sitelerini belirledikten sonra bunları silebilirsiniz! İşte yazım: SharePoint Online'da Site Koleksiyonu Nasıl Silinir?
Sonuç olarak, SharePoint Online'da kullanılmayan tüm siteleri son değiştirilme tarihine göre bulmak, SharePoint ortamınızı düzenli ve verimli bir şekilde çalıştırmanıza yardımcı olabilir. SharePoint Yönetim Merkezi ve PowerShell'i kullanarak, belirli bir süre içinde değiştirilmemiş tüm sitelerin listesini alabilirsiniz. Bu bilgiyi aldıktan sonra artık kullanılmayan siteleri silmeye veya arşivlemeye karar verebilirsiniz.

