Get all user properties using pnp js

In this article. I have explained how to get all the properties of the SharePoint user using pnp js.

For example the sample properties listed below:-

  • PictureURL
  • Department
  • Manager
  • FirstName
  • LastName

and lot more properties

In my previous i have written about how to retrieve current user properties using pnp js.

It will return some basic user properties like loginname, Title, etc…

Now let see how to done the it using PNP JS in the simplest way.

Import the PNP library from node

import pnp from "@pnp/pnpjs"; 

//For demo purpose hard-coded the loginname of the user

let loginName = "i:0#.f|membership|";

pnp.sp.profiles.getPropertiesFor(loginName).then(resp => {
        let props = {}{
            props[val.Key] = val.Value

        console.log("props", props)

It will return the successful response like below in JSON format

you can also use same JavaScript library of PNP Js in your normal JavaScript projects like Content editor webparts like below snippet

//Directly called library form CDN for reference

<script type="text/javascript" src=""/>

<script type="text/javascript">

var loginName = "i:0#.f|membership|";

        var props = {}{
            props[val.Key] = val.Value
        console.log("props", props)


Download it form CDN.

In my upcoming blogs let discuss more operations using PNP JS

Happy SharePointing !…

Author Profile

Vinodh is a Microsoft MVP for SharePoint (Office Apps and Services) having 5+ years of experience in Microsoft Technologies.

His interest and expertise includes SharePoint Online Development, PowerApps Development, Flows for SharePoint and PowerApps. Single Page Apps/Add ins for SharePoint using React, Angular. SharePoint Farm Management, 2, 3 and upto 6 tier SharePoint Farm Installation and Configuration.

Awards :
Microsoft Most Valuable Professional for SharePoint and Office 365 awarded for the year 2016, 2017 and 2018.
C# Corner Most Valuable Professional for SharePoint and Office 365 awarded for the year 2016, 2017 and 2018.
Technology Expertise :
SharePoint Online, SharePoint 2013, SharePoint 2016 and SharePoint 2019 Preview.
Intranets both Modern and Classic, SharePoint Frameworks Customisation, SharePoint Add-ins, SharePoint single page apps.
Angular 5 with Bootstrap single page apps.
Typescript, JQuery and Javascript.
Micrsoft Flow and Powerapps.
Utilised :
Microsoft Graph API, SharePoint REST, SharePoint PnP JS.
Out of Box :
Consume Content search web parts for internet publishing sites using custom display templates.
Having knowledge on SharePoint workflows and SharePoint Designer workflows.
List customisation using JS Link, JSON Formatting.
Having knowledge in Active directory management services.
Create and configure service applications in SharePoint (MMS, UPSA, SSA).
Configure Outgoing email settings using SMTP Services.

Add a Comment

Your email address will not be published. Required fields are marked *