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.
Thanks for putting this out there. Sometimes you just need to stop looking at the code for a second to realize your mistake 🙂