Forum Discussion
Sharepoint and powershell add users to a "people webpart"
For the record, I quickly found the answer.
***
Connect-PnPOnline https://imperiallondon.sharepoint.com/sites/xxxxxxxx
$page = Get-PnPClientSidePage -Identity "xxxx.aspx"
$page.Controls
***
then
***
Connect-PnPOnline https://imperiallondon.sharepoint.com/sites/xxxx
$page = Get-PnPClientSidePage -Identity "yyyy.aspx"
$z_users = $page.Controls | ? {$_.InstanceId -eq "5a7db05e-75xxxx-b01dc1549e"}< id from the above code.>
$z_users.HtmlProperties
$z_users.title = "XXX Users"
$page.Save()
******
Connect-PnPOnline https://imperiallondon.sharepoint.com/sites/xxxxx
$page = Get-PnPClientSidePage -Identity "zzz.aspx"
$peoplepart = $page.Controls | ? {$_.Title -eq "z_users"}
<then a for loop that populated a string ($web_content) with users inserted into it>
$peoplepart.PropertiesJson = $web_content
$page.Save()
***
If you dont know the format of the string web_content. Create a people webpart and populate it with two users, then use powershell to view it.