I am trying to update the Site Logo Url for all the sites in my web application with powershell. The script executes correctly in my dev environment but fails to execute in production and gives an error:
Exception calling "Update" with "0" argument(s): "Object reference not set to an instance of an object."
At D:\Set-WebAppLogoUrl.ps1:28 char:11
+ $_.Update <<<< ();
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
I logged in the system with a farm account but still get the error. Any help would be appreciated. Below is my PS Script I am trying to execute:
$siteUrl = "http://mysite/sites/it"
$rootSite = New-Object Microsoft.SharePoint.SPSite($siteUrl)
$spWebApp = $rootSite.WebApplication
foreach($site in $spWebApp.Sites) {
$site.AllWebs | foreach {
$_.SiteLogoUrl = "/PublishingImages/companylogo.gif";
$_.Update();
}
}
$rootSite.Dispose()