spo userprofile set [options]
Sets user profile property for a SharePoint user
| Option | Description |
| ----------------------- | ----------------------------------------- |
| -u, --userName <userName> | Account name of the user |
| -n, --propertyName <propertyName> | The property name of the property to be be set |
| -v, --propertyValue <propertyValue> | The value of the property to be set |
| -o, --output [output] | Output type. json,text. Default text |
| --verbose | Runs command with verbose logging |
| --debug | Runs command with debug logging |
Updates single value property of a user profile with property name _SPS-JobTitle_ and property value 'Senior Developer'
spo userprofile set --name '[email protected]' --propertyName 'SPS-JobTitle' --propertyValue 'Senior Developer'
Updates multi value property of a user profile with property name _SPS-Skills_ and property values 'CSS', 'HTML'
spo userprofile set --name '[email protected]' --propertyName 'SPS-Skills' --propertyValue 'CSS','HTML'
This command requires tenant admin permissions in case of updating properties other than the current logged user.
This is REST request for updating a single value property that can be implemented in the command. It uses fetch that will have to change within a CLI command with the request library.
fetch(`https://mytenant.sharepoint.com/sites/finder-en/_api/contextinfo`, {
headers: {
"Accept": "application/json;odata=nometadata",
"Content-type": "application/json;odata=verbose"
},
method: "POST"
}).then((response) => {
if (!response.ok) {
console.log(response);
}
return response.json();
}).then((response) => {
console.log(response);
fetch(`https://mytenant.sharepoint.com/sites/finder-en/_api/SP.UserProfiles.PeopleManager/SetSingleValueProfileProperty`, {
headers: {
"Accept": "application/json;odata=nometadata",
"Content-type": "application/json;odata=verbose",
"X-RequestDigest": response.FormDigestValue
},
method: "POST",
body: JSON.stringify({
'accountName': "i:0#.f|membership|[email protected]",
'propertyName': "finderCommunityOfPracticeBody1",
'propertyValue': "Velin Test gfdgf"
})
}).then((response) => {
if (!response.ok) {
console.log(response);
}
return response.json();
}).then((response) => {
console.log(response);
})
})
This is REST request for updating a multi value property that can be implemented in the command. It uses fetch that will have to change within a CLI command with the request library.
fetch(`https://mytenant.sharepoint.com/sites/finder-en/_api/contextinfo`, {
headers: {
"Accept": "application/json;odata=nometadata",
"Content-type": "application/json;odata=verbose"
},
method: "POST"
}).then((response) => {
if (!response.ok) {
this.handleResponseError(response);
reject(response);
}
return response.json();
}).then((response) => {
console.log(response);
fetch(`https://mytenant.sharepoint.com/sites/finder-en/_api/SP.UserProfiles.PeopleManager/SetMultiValuedProfileProperty`, {
headers: {
"Accept": "application/json;odata=nometadata",
"Content-type": "application/json;odata=verbose",
"X-RequestDigest": response.FormDigestValue
},
method: "POST",
body: JSON.stringify({
'accountName': "i:0#.f|membership|[email protected]",
'propertyName': "finderSkills",
'propertyValues': ["Technology1", "Written Communication2"]
})
}).then((response) => {
if (!response.ok) {
console.log(response);
}
return response.json();
}).then((response) => {
console.log(response);
})
})
Set-PnPUserProfileProperty - https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/set-pnpuserprofileproperty?view=sharepoint-ps
See remarks from #1670. As for description, I'd suggest we rephrase it to Sets user profile property for a SharePoint user (single property) since the command allows you to update only one property at the time. If we used -u for user, then we could use -n and -v for name and value. What do you think?
Changed according the comments. Thank you!
Hey guys, can I take this up?
All yours Aakash @aakashbhardwaj619 . Thank you for your support!