SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
look into… to access your webparts... – Mike Apr 5 '12 at 14:55
@Mike Tried it, same error pops up. Any clue? – Bart De Vos Apr 6 '12 at 8:43
up vote 3 down vote accepted

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"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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