Is there anyway to check if a use exists in a office 365 site. I am adding meta data to items in a document library and I am using ensureuser but if the user is not there I don't want it to be added so before I use ensureuser is there anyway of checking whether the user exists in the site or not? This is a powershell script csom

1 Answer 1


The SharePoint Online PowerShell Management Shell lets you query a site and get the users of that site. Searching for the exact user will either return the user record if found or throw a User not found exception if the user doesn't exist on the site.

$site = Get-SPOSite https://contoso.sharepoint.com
Get-SPOUser -Site $site -LoginName [email protected]

DisplayName : Jane Smith
LoginName   : [email protected]
IsSiteAdmin : False
IsGroup     : False
Groups      : {}
  • what do I need to install because its just saying get-spouser is not recognised
    – bendon
    Commented Jul 16, 2015 at 9:28
  • You need to install the management shell. I've added the link to the answer.
    – Zach
    Commented Jul 16, 2015 at 15:42
  • is there not a way to do this with the regular powershell?
    – bendon
    Commented Jul 16, 2015 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.