You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to script a standard SP site look, as part of this I am populating a People Web Part called 'Meet the Team' with the M365 group members.
I can build a user list and it shows them in the People web part but the images dont show. Looking at the export xml of a working web part created manually, and a non working one created by PowerShell I can see that the web part object has a property called HtmlPropertiesData that isnt correct when built by code.
My code looks like below (not sure why this forum is saying there's a missing brace but there isnt, I think its the $_. it doesnt like)
I have tried to update that HtmlPropertiesData using
`$HtmlPropertiesData = 'my updated html formating code'
$PeopleWebPart.HtmlPropertiesData = $HtmlPropertiesData
But it says the property is read only. ChatGPT gave me a load of nonsense to try, which didn't work unsurprisingly. I cannot find any way to update this so the People Web Part displays correctly when I build it via code
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to script a standard SP site look, as part of this I am populating a People Web Part called 'Meet the Team' with the M365 group members.
I can build a user list and it shows them in the People web part but the images dont show. Looking at the export xml of a working web part created manually, and a non working one created by PowerShell I can see that the web part object has a property called HtmlPropertiesData that isnt correct when built by code.
My code looks like below (not sure why this forum is saying there's a missing brace but there isnt, I think its the $_. it doesnt like)
$Site = Get-PNPSite -includes GroupId$Page.Controls | Where-Object {($ .Title -eq "People") -and ($.HTMLPropertiesData -like "Meet The Team")}
$GroupId = $Site.GroupId
$Page = Get-PnPPage -Identity ResourceCentre.aspx
$PeopleWebPart =
$WebPartProperties = $PeopleWebPart.PropertiesJson | ConvertFrom-Json
$GroupMembers = Get-PnPMicrosoft365Group -Identity $GroupId | Get-PnPMicrosoft365GroupMembers
Write-Host ("Current users",$WebPartProperties.persons)
$WebPartProperties.persons = @()
foreach ($User in $GroupMembers) {
$WebPartProperties.persons += [PSCustomObject] @{
id = $User.UserPrincipalName
upn = $User.UserPrincipalName
role = $User.DisplayName
department = ''
phone = ''
sip = ''
aadObjectId = $User.Id
}
}
Set-PnPPageWebPart -Page $Page.Name -Identity $PeopleWebPart.InstanceId -PropertiesJson ($WebPartProperties | ConvertTo-Json -Compress)`
I have tried to update that HtmlPropertiesData using
`$HtmlPropertiesData = 'my updated html formating code'
$PeopleWebPart.HtmlPropertiesData = $HtmlPropertiesData
But it says the property is read only. ChatGPT gave me a load of nonsense to try, which didn't work unsurprisingly. I cannot find any way to update this so the People Web Part displays correctly when I build it via code
Beta Was this translation helpful? Give feedback.
All reactions