Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
1.8k views
in SharePoint Server by 16 16 22

How can I check if the SharePoint Group is already exist or not using PowerShell in SharePoint 2019?

I got the specified name is already in use, and I need to check first if the group exist with the same name or not using PowerShell? How can I do that in SharePoint 2019?

check if group exist in SharePoint 2019 PowerShell


1 Answer

1 like 0 dislike
by 163 204 403
selected by
 
Best answer

Check if SharePoint Groups already exist using PowerShell

To check if SharePoint Groups already exist using PowerShell, you have to do the following:

  1. Open Windows PowerShell ISE as Administrator.
    Windows PowerShell ISE as Administrator
  2. Run the below script

     $spGroupName  = "Group Name"
     $spSiteURL = "Site URL"
     $spweb = Get-SPWeb -Identity $spSiteURL
     #Check if SharePoint Group already exists
         if ($spweb.SiteGroups[$spGroupName] -ne $null) 
           { 
              write-Host  "The $spGroupName is found at $spSiteURL"
           } 
          else 
           { 
              # do your code
           }
    

Check also Get all Groups a user is a member of Using PowerShell

If you don’t ask, the answer is always NO!
...