How to change the JSLink property of the Blog posts Web part in Default.aspx page of a blog site using powershell ? I tried the code below
$SPsite = Get-SPWeb -Identity "http://blogpostsiteurl"
$webpartmanager = $SPsite.GetLimitedWebPartManager("/default.aspx",
[System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
for($i=0;$i -lt $webpartmanager.WebParts.Count;$i++) {
if($webpartmanager.WebParts[$i].title -eq "Posts")
{
$wp=$webpartmanager.WebParts[$i];
$wp.JSLink="~sitecollection/_catalogs/masterpage/blogpost.js";
$webpartmanager.SaveChanges($wp);
break;
}
}
$SPsite.Update();
$SPsite.Dispose();
But i get the error
Exception calling "GetLimitedWebPartManager" with "2" argument(s): "Value does
not fall within the expected range."
Can someone help me with what I am doing wrong?
Thanks!