Skip to content

spo user ensure

Ensures that a user is available on a specific site


m365 spo user ensure [options]


-u, --webUrl <webUrl>
Absolute URL of the site.
--aadId [--aadId]
Id of the user in Azure AD. Specify either aadId or userName but not both.
--userName [userName]
User's UPN (user principal name, e.g. Specify either aadId or userName but not both.
-h, --help [help]
Output usage information. Optionally, specify which section of command's help you want to see. Allowed values are options, examples, remarks, response, full. Default is full.
--query [query]
JMESPath query string. See for more information and examples
-o, --output [output]
Output type. json,text,csv,md. Default json
Runs command with verbose logging
Runs command with debug logging


Ensures a user by its Azure AD Id

m365 spo user ensure --webUrl --aadId e254750a-eaa4-44f6-9517-b74f65cdb747

Ensures a user by its user principal name

m365 spo user ensure --webUrl --userName


  "Id": 35,
  "IsHiddenInUI": false,
  "LoginName": "i:0#.f|membership|",
  "Title": "John Doe",
  "PrincipalType": 1,
  "Email": "",
  "Expiration": "",
  "IsEmailAuthenticationGuestUser": false,
  "IsShareByEmailGuestUser": false,
  "IsSiteAdmin": false,
  "UserId": {
    "NameId": "1003200274f51d2d",
    "NameIdIssuer": "urn:federation:microsoftonline"
  "UserPrincipalName": ""
Email                         :
Expiration                    :
Id                            : 35
IsEmailAuthenticationGuestUser: false
IsHiddenInUI                  : false
IsShareByEmailGuestUser       : false
IsSiteAdmin                   : false
LoginName                     : i:0#.f|membership|
PrincipalType                 : 1
Title                         : John Doe
UserId                        : {"NameId":"1003200274f51d2d","NameIdIssuer":"urn:federation:microsoftonline"}
UserPrincipalName             :
35,,i:0#.f|membership|,John Doe,1,,,,,,"{""NameId"":""100320009d80e5de"",""NameIdIssuer"":""urn:federation:microsoftonline""}",
# spo user ensure --webUrl "" --userName ""

Date: 18/02/2023

## John Doe (35)

Property | Value
Id | 35
IsHiddenInUI | false
LoginName | i:0#.f\|membership\|
Title | John Doe
PrincipalType | 1
Email |
Expiration |
IsEmailAuthenticationGuestUser | false
IsShareByEmailGuestUser | false
IsSiteAdmin | false
UserId | {"NameId":"100320009d80e5de","NameIdIssuer":"urn:federation:microsoftonline"}
UserPrincipalName |