Sharepoint and powershell add users to a "people webpart"

Copper Contributor

I don't even know its possible. 

I have several groups and each group has its own sharepoint page (as it happens within the same site).

I wish to have a "people webpart" which lists users in that group. Some groups will have "1" user some groups up to ten.  

Users for each group are in their own AD distribution list.

 

What I am thinking is powershell looks for the users in the AD group and populates the webpart for each group. 

 

If it is possible, is there any code I can see to "get my head around it". Even just viewing existing people in the webpart from powershell would be good. 

 

As ever with sharepoint I fear I am misunderstanding how it is meant to be used. 

 

1 Reply

For the record, I quickly found the answer.

***

Connect-PnPOnline https://sharepoint.com/sites/xxxxxxxx
$page = Get-PnPClientSidePage -Identity "xxxx.aspx"
$page.Controls

***

then 

***

Connect-PnPOnline https://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://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.