4

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

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 jsmith@contoso.com

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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