Skip to content

SPSite: Get-TargetResource uses empty Property for RootWeb Name #1441

@ChristophHannappel

Description

@ChristophHannappel

Problem description

When getting the Site Collection RootWeb Title the Get-TargetResource uses the Property Name, which is empty on SPWeb Objects.
In this case the Title property contains the name of the RootWeb. Or the Multilanguage approach .TitleResource.GetValueForUICulture()

$site.RootWeb | Select-Object -Property Name, Title
Name Title         
---- -----         
     My Fancy Title

Verbose logs

VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = ResourceGet,'className' = MSFT_DSCLocalConfigurati
onManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfiguration'.
VERBOSE: An LCM method call arrived from computer WFHHPQW003 with user sid S-1-5-21-<Numbers>-<Numbers>-<Numbers>-<Numbers>.
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Getting site collection https://sharepoint.contoso
.com/sites/hannapch-title
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Executing as the local run as user DOMAIN\DSCRunAsAccount
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Leaving BeginProcessing Method of Get-SPSite.
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Leaving ProcessRecord Method of Get-SPSite.
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Leaving EndProcessing Method of Get-SPSite.
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Leaving BeginProcessing Method of New-SPClaimsPrincipal.
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Leaving ProcessRecord Method of New-SPClaimsPrincipal.
VERBOSE: [WFHHPQW003]:                            [[SPSite]DirectResourceAccess] Leaving EndProcessing Method of New-SPClaimsPrincipal.
VERBOSE: [WFHHPQW003]: LCM:  [ End    Get      ]  [[SPSite]DirectResourceAccess]  in 8.5400 seconds.
VERBOSE: [WFHHPQW003]: LCM:  [ End    Set      ]    in  8.8780 seconds.
VERBOSE: Operation 'Invoke CimMethod' complete.


ConfigurationName        : 
DependsOn                : 
ModuleName               : SharePointDSC
ModuleVersion            : 5.4.0
PsDscRunAsCredential     : 
ResourceId               : 
SourceInfo               : 
AdministrationSiteType   : None
CompatibilityLevel       : 15
ContentDatabase          : ContentDatabase
CreateDefaultGroups      : True
Description              : 
HostHeaderWebApplication : 
Language                 : 1031
Name                     : 
OwnerAlias               : <DOMAIN\Username>
OwnerEmail               : <MyMailAddress>
QuotaTemplate            : 
SecondaryEmail           : 
SecondaryOwnerAlias      : 
Template                 : STS#3
Url                      : https://sharepoint.contoso.com/sites/hannapch-title
PSComputerName           : localhost

DSC configuration

SPSite TitleCollection
{
    PsDscRunAsCredential = $cred   
    Url = 'https://sharepoint.contoso.com/sites/hannapch-title'
    OwnerAlias = 'DOMAIN\Username'
}

Suggested solution

Replace Name = $site.RootWeb.Name with $site.RootWeb.TitleResource.GetValueForUICulture($site.RootWeb.UICulture)

SharePoint version and build

SharePoint Server Subscription Edition: 16.0.17928.20238

Operating system the target node is running

OsName               : Microsoft Windows Server 2022 Datacenter
OsOperatingSystemSKU : DatacenterServerEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 20348.1.amd64fre.fe_release.210507-1500
OsLanguage           : en-US
OsMuiLanguages       : {en-US}

PowerShell version and build the target node is running

Name                           Value                                                                                                      
----                           -----                                                                                                      
PSVersion                      5.1.20348.2760                                                                                             
PSEdition                      Desktop                                                                                                    
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                    
BuildVersion                   10.0.20348.2760                                                                                            
CLRVersion                     4.0.30319.42000                                                                                            
WSManStackVersion              3.0                                                                                                        
PSRemotingProtocolVersion      2.3                                                                                                        
SerializationVersion           1.1.0.1

SharePointDsc version

Name          Version Path                                                                             
----          ------- ----                                                                             
SharePointDSC 5.4.0   C:\Program Files\WindowsPowerShell\Modules\SharePointDSC\5.4.0\SharePointDSC.psd1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions