Comments (9)
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.
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.
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.
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.
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.
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.
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.
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.
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.
@asestromsrud can you share the error your receive?
from pnp-powershell.
Related Issues (20)
- [BUG] Set-PnPGroup -SetAssociatedGroup Owners: Access denied.
- Example 1 incorrect on Clear-PnPRecycleBinItem Microsoft Docs page HOT 1
- Get-PnPTerm unable to retrieve labels HOT 2
- [BUG]
- [BUG] Term Store PnP functions fail when using Connect-PnPOnline -SPOManagementShell HOT 7
- [BUG]? - Grant-PnPTenantServicePrincipalPermission timing out HOT 2
- [BUG] false error reported from Add-PnPFolder on large Library
- Connect-PnPOnline- with an option of -ClientId and -ClientSecreat connects successfully but then get unauthorized(401)) for subsequent request example Get-PNPList etc.
- Critical problem with Apply-PnPProvisioningTemplate cmdlet: personal view is created as public view in the destination site
- [BUG] - Move-PnPFolder : The underlying connection was closed: A connection that was expected to be kept alive was closed by the server.
- [BUG] Get-PnPSite -Includes Usage Shows Zero for Bandwidth, Hits, Visits
- [BUG] "The user cannot create group sites in this tenant instance." HOT 3
- [BUG] ConvertTo-PnPClientSidePage fails at OfficeDevPnP.Core.Pages.ClientSidePage.AvailableClientSideComponents(String name) - A critical error occurred - transformation did not complete
- [BUG] Get-PnPTerm throws misleading error if term not found
- [BUG] Add-PnPWebhookSubscription. Body empty.
- [BUG]
- Get-PnPFolder : A parameter cannot be found that matches parameter name 'List'[BUG]
- [BUG] Search bar for List gets enabled while trying to hide suitebar search using "Set-PnPSearchSettings -SearchBoxInNavBar Hidden -Scope Web". Is there any way to hide search bar for list too.
- [BUG] GCC High client tokens Confidential Client is not supported in Cross Cloud request
- Set-PnPSite command reporting (401) Unauthorized Error, in environment where legacy authentication is blocked HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pnp-powershell.