Hi
I am trying to edit an Online Theme using a PowerShell code. The PowerShell code works but generate an error message:
******************Code******************
$loc = "C:\Users\user1\Desktop\dll\" # Location of DLL''s
$siteUrl = "https://MySite.sharepoint.com/sites/Dev1"
$loginname = "User1@Outlook.com"
Set-Location $loc
Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Runtime.dll")
$siteUrl = "https://MySite.sharepoint.com/sites/Dev1"
$loginname = "User1@Outlook.com"
Set-Location $loc
Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.dll")
Add-Type -Path (Resolve-Path "Microsoft.SharePoint.Client.Runtime.dll")
Write-Host "Please enter password for $($siteUrl):"
$pwd = Read-Host -AsSecureString
$pwd = Read-Host -AsSecureString
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteUrl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($loginname, $pwd)
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($loginname, $pwd)
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()
$web.MasterUrl = "/sites/Dev1/_catalogs/masterpage/oslo.master";
$web.CustomMasterUrl = "/sites/Dev1/_catalogs/masterpage/oslo.master";
$web.ApplyTheme("/sites/Dev1/_catalogs/theme/15/palette005.spcolor","/sites/Dev1/_catalogs/theme/15/fontscheme003.spfont","/_layouts/15/images/image_bg005.jpg",$true)
$web.CustomMasterUrl = "/sites/Dev1/_catalogs/masterpage/oslo.master";
$web.ApplyTheme("/sites/Dev1/_catalogs/theme/15/palette005.spcolor","/sites/Dev1/_catalogs/theme/15/fontscheme003.spfont","/_layouts/15/images/image_bg005.jpg",$true)
$web.update()
$ctx.Load($web)
$ctx.ExecuteQuery()
Write-Host "Title" $web.Title " has been updated"
$ctx.Load($web)
$ctx.ExecuteQuery()
Write-Host "Title" $web.Title " has been updated"
****************************************
############### Error ############
Exception calling "ExecuteQuery" with "0" argument(s): "The web being updated was changed by an external process."
At line:26 char:1
+ $ctx.ExecuteQuery()
+ ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ServerException
###############################
I hope you can help
Colin