1

I have the following page: test.aspx

enter image description here

But when I run Get-PnPClientSidePage, I do not see it as a value, even if I expand any of the items listed. Additionally, I don't see a description either.

enter image description here

Once I have the department value, I would like to set it to something else.

2 Answers 2

0

Get-PnPClientSidePage is now renamed to Get-PnPPage from PnP PowerShell v0.3.15. I will suggest you to update PnP PowerShell version, follow: Updating PnP PowerShell

Anyways, you can use below simpler PnP PowerShell script to get the department value from site pages library:

$page = Get-PnPFile -Url "/sites/work/SitePages/PageProperties.aspx" -AsListItem
$page["Department"]

Where Department is internal name of your column. You can get the exact internal name of your column by following this article: How to find the Internal name of columns in SharePoint Online?

Site page properties:

enter image description here

Output:

enter image description here


Then you can set the new value to department column using:

$page["Department"] = "Power Platform CoE"
$page.Update()
Invoke-PnPQuery

Output:

enter image description here

Site page properties:

enter image description here

0

You can use following code to get existing value:

Connect-PnPOnline -Url "SiteUrl" -Interactive
$page = Get-PnPClientSidePage "Test.aspx"
$listItem = Get-PnPListItem -List "Site Pages" -Id $page.PageId
Write-Host $listItem["Department"]

You can use following code to set value:

Connect-PnPOnline -Url "SiteUrl" -Interactive
$page = Get-PnPClientSidePage "Test.aspx"
$listItem = Get-PnPListItem -List "Site Pages" -Id $page.PageId
$listItem["Department"] = "Department1"
$listItem.Update()
$listItem.Context.ExecuteQuery()

Make sure that in $listItem["Department"] you use correct internal name of of your field. Check this to get your internal name of the field.

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.