1

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

1 Answer 1

1

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"]

6
  • 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. Commented Mar 22, 2013 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
    Commented Mar 22, 2013 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. Commented Mar 25, 2013 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. Commented Mar 25, 2013 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 Commented Mar 25, 2013 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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