Hi @Sergio Londono,
I apologize that I didn't make the third part clearer. I will restate that part here. Please forgive me for modifying your comment to remove my tenant's name, as I accidentally gave out my tenant's name.
The purpose of this PowerShell is to hide all sync buttons on a site collection and its subsites. So $SiteURL
is the URL of a site collection. You can modify this URL to achieve sync button hiding for other site collections.
1.Download SharePoint Online Management Shell and install it.
2.Modify the PowerShell commands I provided. Just modify $SiteURL, $Username, and $Password
. The username and password are the ones you use to log in to Share Point Online. Please make sure that the account you are using is the admin of this site collection.
Function Disable-SPOSyncButton([String]$SiteURL)
{
Try{
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = $Credentials
#Get the Web and Sub Sites
$Web = $Ctx.Web
$Ctx.Load($Web)
$Ctx.Load($Web.Webs)
$Ctx.ExecuteQuery()
$Web.ExcludeFromOfflineClient=$true
$Web.Update()
$Ctx.ExecuteQuery()
Write-Host -f Green "Sync Button is Disabled for the Site:" $($SiteURL)
#Iterate through each subsite of the current web
ForEach ($Subweb in $Ctx.Web.Webs)
{
#Call the function recursively
Disable-SPOSyncButton -SiteURL $Subweb.url
}
}
Catch {
write-host -f Red "Error Disabling Sync Button!" $_.Exception.Message
}
}
#Set parameter values
$SiteURL="https://Your Site Collection URL"
#Replace Username and Password
$Username = 'YourUserName@tenant.onmicrosoft.com'
$Password = 'YourPassword'
$pass = ConvertTo-SecureString -AsPlainText $Password -Force
$SecureString = $pass
# Users you password securly
$MySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $Username,$SecureString
#Get Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($MySecureCreds.Username, $MySecureCreds.Password)
#Call the function
Disable-SPOSyncButton -SiteURL $SiteURL
3.Open SharePoint Online Management Shell.
4.Copy the commands and press Enter to execute it. After success, you can see the green prompt message.
5.Clear your browser cache and then revisit the site collection and you will see that the sync button is hidden on the site collection and all its subsites.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.