Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > Finding Missing Properties in PnP PowerShell
November 18
Finding Missing Properties in PnP PowerShell

I’ve recently been working with a customer migrating some content from one SharePoint Online Site Collection to another. They have a lot of content, so automating the migrations with PowerShell was really the only we’d be able to get all of their content migrated before we died of old age. Part of what they wanted migrated over was the custom views they had in their Document Libraries. A couple of extra columns here, a grouping there, nothing too complicated. I fired up PowerShell (really VS Code) and started noodling.

Whenever I’m trying something new in PowerShell I have a standard process. I do a Get-Command to see if there’s a cmdlet that does what I need. In this case there were four cmdlets that piqued my interest, Add-PnPView, Get-PnPView, Remove-PnPView, and Set-PnPView. The process seemed super easy, do a Get-PnPView on the source View, gobble up all the details, then spit them back into Add-PnPView on the other site collection. Easy Peasy. Until it isn’t.

Here’s what the view looked like, roughly.

image

I didn’t do much to it. I added a couple of columns, Created By and File Size and set the view to group by Created By. Pretty standard stuff. Here’s what Get-PnPView told me about said view:

image

I can see the columns I added in the ViewFields property, but there’s no sign of the grouping anywhere. Knowing what I know about SharePoint I know that information is stored in a Query, but the ViewQuery property is conspicuously empty. What gives? The PnP, in an effort to be efficient, doesn’t download all of the property values for the objects we get. It downloads the schema, and then a subset of the properties that it thinks you’re most likely to use. What’s a fella to do if the thing you need is not in the PnP’s favorite list of properties? You break out one of the PnP’s overlooked gems, Get-PnPProperty.

image

Here’s the code for it all:

Connect-PnPOnline -Url https://toddklindt.sharepoint.com/sites/8884aced -Credentials Me
Get-PnPView -List Documents
Get-PnPView -List Documents -Identity 3c4126aa-d2fe-4b57-9a70-e03ebb9c76ef
$view = Get-PnPView -List Documents -Identity 3c4126aa-d2fe-4b57-9a70-e03ebb9c76ef
$view
$view | select *
$view.ViewQuery
Get-PnPProperty -ClientObject $view -Property ViewQuery
$view.ViewQuery
$view
$view | select *

Not only does Get-PnPProperty get the value of the Property, but it also populates the property in the variable. If you’re getting a collection of objects and need to pull one property for each of them it looks like this:

Get-PnPView –List Documents
$viewlist| ForEach-Object { Get-PnPProperty -ClientObject $_ -Property ViewQuery, ListViewXml }

That hydrates the ViewQuery and ListViewXml property for all of the objects in $viewlist.

image

It snuck some other properties in too, but I don’t mind.

In this case I was using the View object, but this method is necessary for any PnP object. In the past I’ve had to use it with PnPFile and PnPLists. Sometimes the PnP gives you an error message telling you you need to get the property value, sometimes it’s just empty and you have to know. Either way, it’s worth trying to get the property’s value with Get-PnPProperty.

tk

ShortURL: https://www.toddklindt.com/PoshGetPNPProperty

Comments

How to Link your Roku Player or Roku TV via Roku.com/link?

Let us know about the Roku activation steps. To start with collect all the necessary hardware components. Then start the Roku setup. Ensure you have the necessary cables to make the setup. Also, make sure you have a high-speed internet connection. Nextly proceed with the Roku account creation. If you are an existing user, log in to your account. If not sign up and create a Roku account. Make the appropriate connection between the Roku device and the TV. After connecting the device to the internet, it will ask to update. Once you update it, it will start to reboot. Finally, the activation code will appear on the TV screen, after rebooting. Now type in the code on the activation page. Click submit.

For further clarification on the Roku.com/link, visit https://www.roku-com-link.net/
 on 1/21/2020 4:32 AM

Accounting Writing Services Online

Many students opt to buy Accounting Writing Services Online since most writing companies are good in Online Accounting Writing Services and Coursework Accounting Writing Services.
https://superiorwriters247.com/online-accounting-writing-services/
 on 1/22/2020 2:45 AM

HP Envy 7155 Setup and Installation – 123.hp.com/envy7155

HP Envy 7155 users can read & understand the setup guide. If you are new to this model, take it out from the package, remove the protective tapes, and proceed to slide the cartridge to the respective slot. Turn on the wireless icon & opt for the wireless setup wizard to proceed with the software download. Gets the matching software selecting the best method (download from webpage & using the CD provided)? Suppose if you would like to know more about 123.hp.com/envy7155, try contacting our techies who can guide you 24/7 or visit https://www.b-123-hp.com/123-hp-com-envy7155/

Visit my site: https://www.b-123-hp.com/
 on 1/24/2020 12:38 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person

Twitter


Want a message when I reply to your comment? Put your Twitter handle here.

Attachments

 

 SysKit