1

So we lately encountered a weird problem in our SharePoint 2013 Farm. Our Support wanted a powershell script wich lists all sitecollections and write them into a SharePoint list along with some custom properties saved in the sitecollection description so the whole company can see wich sitecollections are available and for wich purpose.

Now some sitecollection admins allready updated their descriptions wich weren't populated into the list by my script. So I updated them myself and my script worked properly. Here is my Script:

    Add-PSSnapin "Microsoft.SharePoint.PowerShell" –ErrorAction SilentlyContinue

    Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force

    $SiteCollectionSammlungUrl = "https://portal.dev.com/sites/SomeSite"
    $SiteCollectionSammlungListName = "SiteCollection_Sammlung"
    $SiteCollectionSammlungWeb = Get-SPWeb -Identity $SiteCollectionSammlungUrl
    $SiteCollectionSammlungList = $SiteCollectionSammlungWeb.Lists[$SiteCollectionSammlungListName]


    function getListItemID($url){
        $spQuery = New-Object Microsoft.SharePoint.SPQuery
        $spQuery.ViewAttributes = "Scope='Recursive'";
        $spQuery.RowLimit = 1
        $caml = '<Where><Eq><FieldRef Name="SiteCollectionUrl"/><Value Type="Text">'+$url+'</Value></Eq></Where>'
        $spQuery.Query = $caml
        $listItems = $SiteCollectionSammlungList.GetItems($spQuery)
        if($listItems.Count -eq 1){
         ForEach($listItem in $listItems){
         return $listItem.ID
         }
            } else {
         return 0
        }
    }

    function getInformationFromSiteCollection($Site){
            $siteCollectionInformation = New-Object -TypeName PSObject
            Add-Member -InputObject $siteCollectionInformation -Name Title -Value $Site.RootWeb.Title -MemberType NoteProperty
            Add-Member -InputObject $siteCollectionInformation -Name Url -Value $Site.RootWeb.Url -MemberType NoteProperty
            try{$Nutzerkreis = $Site.RootWeb.Description.Split(";")[0].Split(":")[1]}catch{$Nutzerkreis = ""}
            Add-Member -InputObject $siteCollectionInformation -Name Nutzerkreis -Value $Nutzerkreis -MemberType NoteProperty
            try{$Verantwortlicher = $Site.RootWeb.Description.Split(";")[1].Split(":")[1]}catch{$Verantwortlicher = ""}
            Add-Member -InputObject $siteCollectionInformation -Name Verantwortlicher -Value $Verantwortlicher -MemberType NoteProperty
            try{$Nutzungszweck = $Site.RootWeb.Description.Split(";")[2].Split(":")[1]}catch{$Nutzungszweck = ""}
            Add-Member -InputObject $siteCollectionInformation -Name Nutzungszweck -Value $Nutzungszweck -MemberType NoteProperty
            return $siteCollectionInformation
    }




    $webapps = Get-SPWebApplication
    ForEach($webapp in $webapps){
        $Sites = Get-SPSite -Limit all -WebApplication $webapp
        ForEach($Site in $Sites){
            $info = getInformationFromSiteCollection($Site) -ErrorAction 
            $listItemID = 0
            $listItemID = getListItemID($info.Url)
            $subSites = ""
            $Webs = $Site.AllWebs
            ForEach($web in $Webs){   
            if($web.Url -eq $Site.RootWeb.Url){continue}
                $subSites += $web.Url + "`n"
            }
            $web.Dispose()

            Add-Member -InputObject $info -Name SubSites -Value $subSites -MemberType NoteProperty

            if($listItemID -eq 0){
            $listItem = $null
            $listItem = $SiteCollectionSammlungList.Items.Add()
            $listItem["Title"] = $info.Title
            $listItem["SiteCollectionUrl"] = $info.Url
            $listItem["InCharge"] = $info.Verantwortlicher
            $listItem["GroupOfUsers"] = $info.Nutzerkreis
            $listItem["Description"] = $info.Nutzungszweck
            $listItem["SubSites"] = $info.SubSites
            $listItem.Update()

            } else {
            $listItem = $null
            $listItem = $SiteCollectionSammlungList.GetItemById($listItemID)
            $listItem["Title"] = $info.Title
            $listItem["SiteCollectionUrl"] = $info.Url
            $listItem["InCharge"] = $info.Verantwortlicher
            $listItem["GroupOfUsers"] = $info.Nutzerkreis
            $listItem["Description"] = $info.Nutzungszweck
            $listItem["SubSites"] = $info.SubSites
            $listItem.Update()
            }
        }
        $Site.Dispose()
    }

It works well but apparently the rootweb description i get from powershell is not the same as on the website itself wich these two screenshots show: Description from a rootweb in Powershell

Description from the same rootweb in UI

So where is Title and Description for a Web stored and how can it be different for some users or even be different when accessed from powershell or UI? Note that the Web-description always was changed through UI and at least by Sitecollection-Admins. The powershell command was used with Farm-Admin rights.

2

Title and Description can be localized to different languages via "TitleResource" and "DescriptionResource". Perhaps that's what you're experiencing?

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.web_members.aspx

JSOM

var ctx = new SP.ClientContext.get_current();     
this.web= ctx.get_web();    
web.get_titleResource().setValueForUICulture("en-US", "Localize Me");
web.get_titleResource().setValueForUICulture("fi-FI", "Kielikäännä minut");

C#

web.TitleResource.SetValueForUICulture("en-US", "Localize Me");
web.TitleResource.SetValueForUICulture("fi-FI", "Kielikäännä minut");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.