find email id located anywhere under a site collection

Chirag Shukla 41 Reputation points

Hello Friends,

Is there any PowerShell script which can find a specific email ID located anywhere under a site collection? eg: it may be there under group, column name, comments column, etc. Let me know please.



A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
8,578 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,704 questions
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
1,555 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 43,231 Reputation points
    Hello ,
    Yes, this is possible, but through scripting. Here's a PowerShell script example that can help you search for a specific email address within a SharePoint site collection:
    # SharePoint Online Module (for SharePoint Online)
    # Install-Module -Name SharePointPnPPowerShellOnline
    # SharePoint On-Premises Module (for SharePoint On-Premises)
    # Install-Module -Name SharePointPnPPowerShell2019
    # Connect to SharePoint
    Connect-PnPOnline -Url <insertyourSharepointURLhere> -UseWebLogin
    # Specify the email address you want to search for
    $emailToSearch = "<insertheretheemailtocheckfor>"
    # Search for the email address within lists and libraries
    $lists = Get-PnPTenantSite | Get-PnPTenantSiteList
    foreach ($list in $lists) {
        $items = Get-PnPTenantSiteListItem -List $list.Title
        foreach ($item in $items) {
            $fields = Get-PnPTenantSiteListItemFieldValues -List $list.Title -Identity $item.Id
            foreach ($field in $fields.Keys) {
                $fieldValue = $fields[$field]
                if ($fieldValue -match $emailToSearch) {
                    Write-Host "Found in list $($list.Title), item $($item.Id), field $field"
    # Search for the email address in site columns and content types
    $contentTypes = Get-PnPTenantSiteContentType
    foreach ($contentType in $contentTypes) {
        $fields = Get-PnPTenantSiteContentTypeField -Identity $contentType.Name
        foreach ($field in $fields) {
            $fieldXml = $field.SchemaXml
            if ($fieldXml -match $emailToSearch) {
                Write-Host "Found in content type $($contentType.Name), field $($field.InternalName)"
    # Disconnect from SharePoint
    This script uses the SharePoint PnP PowerShell module to connect to your SharePoint site collection. Before using this script, make sure to:
    1.Install the SharePoint PnP PowerShell module appropriate for your SharePoint environment (Online or On-Premises) as shown in the comments at the beginning of the script.
    2.Replace ""https:// your-sharepoint- site-url"" with the actual URL of your SharePoint site collection.
    3.Set $emailToSearch to the email address you want to search for.
    --If the reply is helpful, please Upvote and Accept as answer--
    0 comments No comments