I'm using the code below to edit the image in a webpart:

$webPartCollection = $web.GetWebPartCollection("default.aspx","Shared") 
$imagePart = $webPartCollection | Where-Object { $_.Title -eq "Site Image"}
$imagePart.ImageLink = "web/PublishingImages/myPicture.jpg"

But I'm unable to save the webpart, I get the following error:

Exception calling "SaveChanges" with "1" argument(s): "Could not find file 'C:\ Users\admin\AppData\Local\Temp\2\yqvs9p_s.dll'." At line:1 char:31
+ $webPartCollection.SaveChanges <<<< ($imagePart.StorageKey)
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

What am I doing wrong?
Why is it looking for that (random) dll?


try something like:

$web = Get-SPWeb "http://url"
$page = $web.GetFile("default.aspx")
$wpm = $web.GetLimitedWebPartManager($page.Url, [System.Web.UI.WebControls.WebParts.PersonalizationScope]::Shared)
$wp = $wpm | Where-Object {$$_.Title -eq "Site Image"}
$wp.ImageLink = "web/PublishingImages/myPictue.jpg"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.