0

I am getting an error:

Cannot index into a null array at line with "$Web.Lists"

$web = Get-SPWeb -site "https://dTH.ca/sites/universal"

$list = $web.Lists["Folder Files"]

The same script works well in staging environment but fails in production.

Please suggest!

0

Do u have checked $web to confirm that is Null or Not? I highly recommend that install PnP PowerShell in server(or any other OS) and use that for work with list and lib instead of sharepoint PowerShell.

https://docs.microsoft.com/en-us/powershell/sharepoint/sharepoint-pnp/sharepoint-pnp-cmdlets?view=sharepoint-ps

| improve this answer | |
  • Yes I get a value for $web and Null value for $web.lists. Is it because of space between the document library name. I have also tried $list = $web.Lists["Folder%20Files"] – user91989 Jul 27 at 0:26
  • you can use pnp powershell for it more easy. in there you can pass list display name or List GUID for find a list. – aMir Kazemi Jul 27 at 7:44
0

Use $web = Get-SPWeb -identity "https://dTH.ca/sites/universal"

Change site to identity. I assume you are handling a site collection having a bunch of sub sites. Using site will return all subsites, $web will be collection of sub-sites which does not have a the lists property

| improve this answer | |

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.