PowerShell Exception calling GetLimitedWebPartManager

Using PowerShell against SharePoint, I was trying to remove a web part from a lot of pages.

Time after time I was receiving this error:

Exception calling “GetLimitedWebPartManager” with “2” argument(s): “Unable to cast COM object of type ‘Microsoft.SharePoint.Li
brary.SPRequestInternalClass’ to interface type ‘Microsoft.SharePoint.Library.ISPRequest’. This operation failed because the Q
ueryInterface call on the COM component for the interface with IID

Turned out that I wasn’t trying to work with the correct page. I was trying to work with a web part on a page in a library, but by script was working with a site page.

1 thought on “PowerShell Exception calling GetLimitedWebPartManager

Leave a Reply

Your email address will not be published. Required fields are marked *