locked
Error while updating SiteLogoUrl with Powershell RRS feed

  • Question

  • 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()

    Thursday, October 4, 2012 4:00 AM

Answers

  • Hi,

    For this issue, I would suggest you to check whether the error message happens in a specific web or the first time the code line executes, you can change the code snippet by add the following tracing steps:

    foreach($site in $spWebApp.Sites) { 
    write-host $site.Name;
    $site.AllWebs | foreach { 
    write-host $_.Name;
            $_.SiteLogoUrl = "/PublishingImages/companylogo.gif";
            $_.Update();
        }
    }

    Thanks,
    Qiao
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Qiao Wei

    TechNet Community Support

    • Marked as answer by SharePointGuy Friday, October 5, 2012 9:56 AM
    Friday, October 5, 2012 6:15 AM
    Moderator

All replies

  • Hi,

    For this issue, I would suggest you to check whether the error message happens in a specific web or the first time the code line executes, you can change the code snippet by add the following tracing steps:

    foreach($site in $spWebApp.Sites) { 
    write-host $site.Name;
    $site.AllWebs | foreach { 
    write-host $_.Name;
            $_.SiteLogoUrl = "/PublishingImages/companylogo.gif";
            $_.Update();
        }
    }

    Thanks,
    Qiao
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


    Qiao Wei

    TechNet Community Support

    • Marked as answer by SharePointGuy Friday, October 5, 2012 9:56 AM
    Friday, October 5, 2012 6:15 AM
    Moderator
  • @Qiao: The error message popped up for all webs. However I was able to resolve the issue as there were some problems going on with my prod farm configuration. I worked with our operations team and got that issue resolved and my script worked like a charm.
    Friday, October 5, 2012 9:56 AM