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

Hi I have knocked up a quick powershell function that downloads all the files in my Site Assets dir so that I import these into Visual Studion ( and not the shortcuts if you just copy and paste)

Now you would think the few lines of code would work in the PowerGui debugger wheh run as administrator but hang on, anything involving SHarePoint is never as it seems...

#Set up the object variables
$site= New-Object Microsoft.SharePoint.SPSite ($siteUrl)  # this works
$web=$site.OpenWeb()   # so does this as seen in the debugger
$list=$web.Lists["Site Assets"]  #null and yet when I insepect $web I can see my site asstets
share|improve this question

The code is fine so the problem has to be either with the user account that you are running the script as or with the permissions on the library itself. Try running this as the FARM account and see if you get the same behavior.

The only other suggestion I can make is to change your last line to this:

$list = $site.RootWeb.Lists["Site Assets"]

share|improve this answer
Thanks for your help it's odd when I can happily go and access this file with SPD using my account. Your last suggestions reports an COM exception but it was definitely worth a punt. – westerdaled Mar 22 '13 at 15:42
a COM Exception?!?!?! Now this is really sounding like a permissions issue. Did you try it running the script as the FARM/SYSTEM account? – Dave Wise Mar 22 '13 at 15:48
I am running the the account under system ( I did not set up this dev farm) .. I will have another go a bit later after a reboot ( in case I am suffering some undisposed object issue). Also, I have scripted an unattended farm install for remote working so will also try on the new farm once I have restored the sc on it. – westerdaled Mar 25 '13 at 7:52
Hmmmmm the plot thickens. Following a reboot of this dev farm. I notice that SharePoint\system has limited access permissions to /Site Assets - tho this maybe ok. However more worryingly, when I explore the SPList object with PowerGUI I noticed Root folder gives an exception and the IsSiteAssetsLibrary gives an Exception. – westerdaled Mar 25 '13 at 9:19
Dave ... You are right on the money. Gave the appropriate access to SharePoint\System and lol Site Assets is no longer null...Thanks very much – westerdaled Mar 25 '13 at 9:32

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.