Hey all, i’m looking for some scripting help.
Basically what I am trying to do is get all Site Collections under a specific Web Application, then apply the properties for MasterUrl, CustomMasterUrl and AlternateCssUrl.
Here is the script I have, which is not working as it tells me ‘The Properties do not exist’:
Get-SPSite -ContentDatabase SP_CONTENT | foreach-object {
$_.MasterUrl = “/_catalogs/masterpage/cs1_sp2010.master”
$_.CustomMasterUrl = “/_catalogs/masterpage/cs1_sp2010.master”
$_.alternatecssurl = “/Style Library/cs1_sp2010.css”;
$_.Update()
}
When executing Get-SPSite -ContentDatabase SP_CONTENT, I receive the list of site collections (which is approximately 15 in this case). Results of the Get statement below:
Url
—
http://web.site.com
http://web.site.com/app/branding
http://web.site.com/app/bree
http://web.site.com/app/carrepairs
http://web.site.com/app/invoicing
http://web.site.com/app/sctrack
http://web.site.com/dept/Equip
http://web.site.com/dept/Finance
http://web.site.com/dept/FM
http://web.site.com/dept/HR
http://web.site.com/dept/IT
http://web.site.com/dept/it/pmo
http://web.site.com/dept/Laws
http://web.site.com/dept/QA
http://web.site.com/dept/QITS
http://web.site.com/dept/SRStuff
When executing the full PowerShell script in blue above, here are the errors received:
Property ‘MasterUrl’ cannot be found on this object; make sure it exists and is
settable.
At E:\scripts\Branding\Branding-AAA-TEST-Apply_MasterPages_CSS_to_INSIDEQA_Site
s.ps1:2 char:8
+ $_. <<<< MasterUrl = “/_catalogs/masterpage/cs1_sp2010.master”
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Property ‘CustomMasterUrl’ cannot be found on this object; make sure it exists
and is settable.
At E:\scripts\Branding\Branding-AAA-TEST-Apply_MasterPages_CSS_to_INSIDEQA_Site
s.ps1:3 char:8
+ $_. <<<< CustomMasterUrl = “/_catalogs/masterpage/cs1_sp2010.master”
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Property ‘alternatecssurl’ cannot be found on this object; make sure it exists
and is settable.
At E:\scripts\Branding\Branding-AAA-TEST-Apply_MasterPages_CSS_to_INSIDEQA_Site
s.ps1:4 char:8
+ $_. <<<< alternatecssurl = “/Style Library/cs1_sp2010.css”;
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyAssignmentException
Method invocation failed because [Microsoft.SharePoint.SPSite] doesn’t contain
a method named ‘Update’.
At E:\scripts\Branding\Branding-AAA-TEST-Apply_MasterPages_CSS_to_INSIDEQA_Site
s.ps1:5 char:14
+ $_.Update <<<< ()
+ CategoryInfo : InvalidOperation: (Update:String) [], RuntimeExc
eption
+ FullyQualifiedErrorId : MethodNotFound
Any help is appreciated, thanks!
$mainurl = “http://vlad.test.loc”
$cssurl = $mainurl + “/Style%20Library/MyCss/styles.css”
$web = Get-SPWeb $mainurl
$web.AlternateCssUrl = $cssurl
$web.AllProperties[“__InheritsAlternateCssUrl”] = $True
$web.Update()
Try this for now, I got to go for now, Will check more in like 1h