How To Create SharePoint 2013 Custom Group Using Powershell Commands

Steps
 
Start your Windows PowerShell on your computer.
Right click and select Run as administrator option.

Paste the below script on the PowerShell window and click the enter button.

Check your SharePoint site Feature will activate successfully.

Syntax Explanation

Delete-SPGroup "http://gowtham.sharepoint.com/teams/tutorials" "SharePointOwners"

This example deletes SharePoint group "SharePointOwners" at the given site collection
  1. Code:  
  2.   
  3. Function Delete-SPGroup()  
  4. {  
  5.    
  6. [CmdletBinding()]  
  7. Param(  
  8.     [Parameter(Mandatory=$true)][string]$SiteURL,  
  9.     [Parameter(Mandatory=$true)]$GroupName  
  10.   
  11. )  
  12.    
  13.  #Get the rootweb  
  14.  $web = Get-SPWeb $SiteURL  
  15.   
  16.  #group  already exists  
  17.   if($Web.SiteGroups[$GroupName] -ne $null)  
  18.    {  
  19.                         #remove sharepoint group using powershell  
  20.                         $web.SiteGroups.Remove($GroupName)  
  21.                         $web.Update()  
  22.       
  23.           Write-Host "Group Deleted!"  
  24.   }  
  25.   else  
  26.     {  
  27.        Write-Host "Group doesn't Exists!"  
  28.     }  
  29.      $web.Dispose()  
  30.  }  
  31.  Delete-SPGroup()  
Ebook Download
View all
Learn
View all