REMOVING GROUP FROM MY SITES USING POWERSHELL

You can use the following script to remove a specific group from MySites in your web application.

The managed path to My Sites can be ‘my’ or ‘personal’. In this case I used ‘my’.

——

$site = get-spsite “http://mysitehost.dev”

$groupName = “group”

foreach($personal in $site.WebApplication.Sites | Where { $_.Url -like “*/my/*” })
{
$groups = $personal.RootWeb.SiteGroups | Where { $_.Name -eq $groupName }
if($groups.Count > 0)
{
$personal.RootWeb.SiteGroups.Remove($groupName)
}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s