Get Value from People Picker in SharePoint Online with PowerShell

1 Comment

When using SharePoint Online as an input for our PowerShell scripts, sometimes we need to get information from a People Picker type of field. Luckily this is pretty easy to do once you know where to look at.

First of all, you will need to use CSOM to get this property, as the Out of the Box SharePoint Online cmdlets to not allow you to do anything under the SPWeb. If you are an IT Pro, you might find PowerShell and CSOM a bit harder to understand and that’s normal. Chris O’Brien has a great blog post to get you started on Using CSOM in PowerShell scripts with Office 365

#First Connect to SharePoint Online
Import-Module Microsoft.Online.SharePoint.PowerShell
$username = "" 
$password = "Password"
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force 
$url = ""
$context = New-Object Microsoft.SharePoint.Client.ClientContext($url) 
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword) 
$context.Credentials = $credentials 
#Get the List and Items
$list = $Context.Web.Lists.GetByTitle("AddDistributionList")
$query = [Microsoft.SharePoint.Client.CamlQuery]::CreateAllItemsQuery(1000) 
$items = $list.GetItems($query)
#Loop Trough the Items
foreach ($item in $items) {
#UserName is our Column Name of type People Picker
$User = $item["Username"].Email
Write-Host $User

Whenever we simply want a string from SharePoint Online, we simply use $item[“ColumnName”] and it works. However that returns nothing for a People Picker Column. For a People Picker Column, here is a screenshot of what properties look like.

Get Value from People Picker in SharePoint Online PowerShell

So if you need the Email, you simply use: item[“ColumnName”].Email . If you want the name, you would use $item[“ColumnName “].LookupValue

Get Value from People Picker in SharePoint Online PowerShell

I hope this was helpful! If you want to learn more about PowerShell for Office 365, check out my Pluralsight course by clicking the banner below!

Learn PowerShell for Office 365

Previous Post
Free Webinar: Creating Dynamic Forms in SharePoint Online Without Any Need for Technical Skills with KWizCom Forms
Next Post
Is Your SharePoint Healthy?

1 Comment

  • October 19, 2020 at 12:40 pm

    Thank you so much for this! Seriously. This was a huge help!


Leave a Reply

15 49.0138 8.38624 1 0 4000 1 300 1