Giter VIP home page Giter VIP logo

Comments (9)

kilasuit avatar kilasuit commented on May 24, 2024

Hi Dean - your getting this error as not all of the Web object properties are brought back on calling Get-SPOWeb

Do you get the same issue if you use Get-SPOWeb | Select-Object *

from pnp-powershell.

DeanGross avatar DeanGross commented on May 24, 2024

No, i get a different error
get-spoweb : The request uses too many resources.
At line:1 char:1

  • get-spoweb | Select-Object *
  • - CategoryInfo          : WriteError: (:) [Get-SPOWeb], ServerException
    - FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.GetWeb
    

from pnp-powershell.

kilasuit avatar kilasuit commented on May 24, 2024

Hi Dean,

The Issue is because not all the properties of the Web object are initialised as part of the Get-SPOWeb function.

At the Hierarchical level the web object contains other objects as can be seen below - not all of them are called back as part of the web object as they aren't normally necessary and therefore they are only returned when explicitly called for.

spoweb-initialized

This is one of the drawbacks of CSOM but the additional code to call and return all the web object properties wouldn't be overly worthwhile (in my opinion)

However that being said perhaps there could be an additional switch for the Get-SPOWeb function that would then make that enhanced call.

@erwinvanhunen - Do you think that adding an additional switch would be worthwhile or more of a headache to implement?

from pnp-powershell.

erwinvanhunen avatar erwinvanhunen commented on May 24, 2024

Adding an additional switch would be pretty complex, given that some properties will fail to load if certain features are not active. It would generate quite an additional load.

I created a new cmdlet: Get-SPOProperty which relatively easily allows to load certain properties:

for instance:

$web = Get-SPOWeb
Get-SPOProperty -ClientObject $web -Property Lists

This will load the lists property and if possible return it's value to the output. You can mix and match, so

Get-SPOProperty -ClientObject (Get-SPOWeb).Lists.GetByTitle("Site Assets") -Property Views

will also work.

A shorthand version of the cmdlet parameters is:

Get-SPOProperty $web Lists

First parameter is the object to use, second parameter is the property to load. You can optionally specifiy a list of properties. It will however not output those values by default, e.g. you have to output them yourself:

Get-SPOProperty -ClientObject $web -Property Lists, Title, Id
$web.Lists
$web.Title
$web.Id

The examples above use a web object, but it applies to any of the objects that are being returned by the cmdlets, so lists, views, content types, etc. etc.

from pnp-powershell.

shurick81 avatar shurick81 commented on May 24, 2024

Hello Erwin, it looks like working approach for many SPOWeb properties, but not for Navigation:

PS C:\Windows\system32> Get-SPOProperty -ClientObject $web -Property Navigation
format-default : The collection has not been initialized. It has not been requested or the request has not been executed. It may need to be explicitly
requested.
+ CategoryInfo : NotSpecified: (:) [format-default], CollectionNotInitializedException
+ FullyQualifiedErrorId : Microsoft.SharePoint.Client.CollectionNotInitializedException,Microsoft.PowerShell.Commands.FormatDefaultCommand

from pnp-powershell.

erwinvanhunen avatar erwinvanhunen commented on May 24, 2024

Sorry for the extremely long delay. The reason for you not being able to load the Navigation element this way is that Navigation object is actually a collection of nodes. PowerShell tries to resolve each property of each node, which also haven't been loaded. Hence the error.

It's possible to chain things:

$w = Get-SPOWeb
$navigation = Get-SPOProperty $w Navigation
$quicklaunch = Get-SPOProperty $navigation QuickLaunch
$topnode = $quicklaunch[0]
$ctx = Get-SPOContext
$ctx.Load($topnode)
Execute-SPOQuery

$topnode.Title

Closing this issues.

from pnp-powershell.

shurick81 avatar shurick81 commented on May 24, 2024

Thank you Erwin, and by the way, it even works without spocontext, so it's even better:

$web = Get-SPOWeb;
$navigation = Get-SPOProperty $web Navigation;
$topNavigationBar = Get-SPOProperty $navigation TopNavigationBar;
$topNavigationBar[0].Title;

I tested with SharePoint 2013

from pnp-powershell.

asestromsrud avatar asestromsrud commented on May 24, 2024

I get the error when adding an item to a tiles list. The item is added but I still get the error on this command:
Add-PnPListItem -List $listName -Web $targetWeb -Values $itemColumns
Why does it work but still return an error? I can't move on afterward.

from pnp-powershell.

erwinvanhunen avatar erwinvanhunen commented on May 24, 2024

@asestromsrud can you share the error your receive?

from pnp-powershell.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.