SharePoint Online: PowerShell kullanan Tüm Siteler için Bir Özelliği Devre Dışı Bırakma
Gereksinim: PowerShell kullanan tüm SharePoint Online siteleri için bir özelliği devre dışı bırakın.
SharePoint yöneticisiyseniz, kuruluşunuzdaki tüm siteler için bir özelliği devre dışı bırakmanız gerekebilecek zamanlar olabilir. Bunu PowerShell kullanarak yapabilirsiniz! Bu blog gönderisinde, PowerShell kullanarak SharePoint Online kiracınızdaki tüm siteler için bir özelliğin nasıl devre dışı bırakılacağı gösterilecektir. Artık kiracınızda etkinleştirilmesini istemediğiniz bir özelliğiniz varsa ve bunu her site için manuel olarak yapmak istemiyorsanız bu yararlı olabilir.
PowerShell, Kiracıdaki Tüm Koleksiyonlarda Bir Site Özelliğini Devre Dışı Bırakacak
Kiracıdaki tüm siteler için SharePoint Online "Belgeleri İstemci Uygulamalarında Varsayılan Olarak Aç" özelliğini devre dışı bırakma gereksinimimiz vardır. Tüm site koleksiyonları için bir özelliği devre dışı bırakmak için PowerShell'i burada bulabilirsiniz.
#Parameters
$TenantAdminURL = "https://crescent-Admin.sharepoint.com"
#Site Collection feature "Open Documents in Client Applications by Default"
$FeatureId = "8a4b8de2-6fd8-41e9-923c-c7c3c00f8295"
#Connect to Admin Center
$Cred = Get-Credential
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
#Get All Site collections - Exclude: Seach Center, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites
$SitesCollections = Get-PnPTenantSite | Where -Property Template -NotIn ("SRCHCEN#0", "REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")
#Loop through each site collection
ForEach($Site in $SitesCollections)
{
#Connect to site collection
Write-host -f Yellow "Trying to Deactivate the feature on site:"$Site.Url
Connect-PnPOnline -Url $Site.Url -Credentials $Cred
#Get the Feature
$Feature = Get-PnPFeature -Scope Site -Identity $FeatureId
#Check if feature is activated
If($Feature.DefinitionId -ne $null)
{
#Disable site collection feature
Disable-PnPFeature -Scope Site -Identity $FeatureId -Force
Write-host -f Green "`tFeature Deactivated Successfully!"
}
Else
{
Write-host -f Cyan "`tFeature is not active!"
}
}
PowerShell Kullanılarak Site Koleksiyonundaki Tüm Siteler İçin Bir Özellik Nasıl Devre Dışı Bırakılır?
Diyelim ki belirli bir site koleksiyonunun tüm weblerinde “İçerik Takip Ediliyor” site özelliğini devre dışı bırakmak istiyoruz:
#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/marketing"
$FeatureId = "a7a2793e-67cd-4dc1-9fd0-43f61581207a" #"Following Content" Web Scoped Feature
#Function to Deactivate a Feature in SharePoint Online Web
Function Deactivate-PnPWebFeature
{
[cmdletbinding()]
Param(
[parameter(Mandatory = $true, ValueFromPipeline = $True)] $Web,
[parameter(Mandatory = $true, ValueFromPipeline = $False)] $FeatureId
)
Try {
Write-host -f Yellow "Trying to Deactivate Feature on:"$web.Url
#Get the Feature to Deactivate
$Feature = Get-PnPFeature -Scope Web -Identity $FeatureId -ErrorAction Stop
#Check if the Feature is Activate
If($Feature.DefinitionId -ne $null)
{
#Deactivate feature
Disable-PnPFeature -Scope Web -Identity $FeatureId -Force -Verbose -ErrorAction Stop
Write-host -f Green "`tFeature Deactivated Successfully!"
}
Else
{
Write-host -f Cyan "`tFeature is not active!"
}
}
Catch {
write-host "`tError Activating Feature: $($_.Exception.Message)" -foregroundcolor Red
}
}
#Connect to the site collection
Connect-PnPOnline -Url $SiteURL -Interactive
#Call the Function for all webs
Get-PnPSubWeb -IncludeRootWeb -Recurse | ForEach-Object { Deactivate-PnPWebFeature $_ -FeatureId $FeatureId}
SharePoint Online: PowerShell kullanarak Tüm Sitelerdeki bir özelliği devre dışı bırakın
Aşağıdaki PowerShell ile kiracının tüm sitelerinden ve alt sitelerinden web kapsamlı bir özelliği devre dışı bırakabiliriz.
#Parameters
$TenantAdminURL = "https://crescent-Admin.sharepoint.com"
$FeatureId = "a7a2793e-67cd-4dc1-9fd0-43f61581207a" #"Following Content" Web Scoped Feature
#Function to Deactivate a Web Feature in SharePoint Online
Function Deactivate-PnPWebFeature
{
[cmdletbinding()]
Param(
[parameter(Mandatory = $true, ValueFromPipeline = $True)] $Web,
[parameter(Mandatory = $true, ValueFromPipeline = $False)] $FeatureId
)
Try {
Write-host -f Yellow "Trying to Deactivate Feature on:"$web.Url
#Get the Feature to Deactivate
$Feature = Get-PnPFeature -Scope Web -Identity $FeatureId -ErrorAction Stop
#Check if the Feature is activated
If($Feature.DefinitionId -ne $null)
{
#Deactivate the feature
Disable-PnPFeature -Scope Web -Identity $FeatureId -Force -ErrorAction Stop
Write-host -f Green "`tFeature Deactivated Successfully!"
}
Else
{
Write-host -f Cyan "`tFeature is not active!"
}
}
Catch {
write-host "`tError Deactivating Feature: $($_.Exception.Message)" -foregroundcolor Red
}
}
#Connect to Admin Center
$Cred = Get-Credential
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Cred
#Get All Site collections - Exclude: Seach Center, Redirect, Mysite Host, App Catalog, Content Type Hub, eDiscovery and Bot Sites
$SitesCollections = Get-PnPTenantSite | Where -Property Template -NotIn ("SRCHCEN#0","REDIRECTSITE#0", "SPSMSITEHOST#0", "APPCATALOG#0", "POINTPUBLISHINGHUB#0", "EDISC#0", "STS#-1")
#Loop through each site collection
ForEach($Site in $SitesCollections)
{
#Connect to site collection
Connect-PnPOnline -Url $Site.Url -Credentials $Cred
#Call the Function for Web and all Subwebs
Get-PnPSubWeb -IncludeRootWeb -Recurse | ForEach-Object { Deactivate-PnPWebFeature $_ -FeatureId $FeatureId}
}
Çözüm
Sonuç olarak, bir özelliğin PowerShell kullanan tüm SharePoint Online siteleri için devre dışı bırakılması büyük bir zaman tasarrufu sağlayabilir ve çok sayıda sitenin yönetimini basitleştirebilir. Kiracınıza bağlanarak, site listesini alarak, özelliğin durumunu doğrulayarak ve özelliği her sitede devre dışı bırakarak SharePoint Online ortamınızı hızlı ve verimli bir şekilde yönetebilirsiniz. Bir özelliğin devre dışı bırakılmasının SharePoint sitelerinin işlevselliğini etkileyebileceğini unutmamak önemlidir; bu nedenle, özelliği tüm siteler için devre dışı bırakmadan önce kapsamlı bir şekilde test etmeniz önerilir. Ayrıca, SharePoint Online ortamınızda herhangi bir değişiklik yapmadan önce verileriniz ve yapılandırmanız için bir yedekleme planına sahip olmak her zaman iyi bir uygulamadır.
