0

I'm using the following PowerShell script to create 15 Site collections. The problem is it only creates only two permission groups and we have to create the rest manually.

Does anyone know a script that creates all the permission groups because when we used this script earlier we create the groups manually we get "sorry this site cannot be shared with you" error.

enter image description here

2
  • 1
    what permission groups you are talking about? by default SharePoint create 3 groups (Site collection name Members, Owners and visitors), are these groups created?
    – Waqas Sarwar MVP
    Commented Mar 7, 2018 at 19:18
  • Have you tried to go to central administration - site collections - change site collection administrators - enter your user as site collection administrator on the site and try again. Then you should have full access and be able to create groups without permission issues.
    – PhilFancy
    Commented Mar 8, 2018 at 7:19

1 Answer 1

0

here you have the snippet

#New-SPSite doesn't create default SharePoint security groups
#Create new site collection default groups and change the title to the desrired one
#as per our framework requirements
$Sitename = 'SiteName'
$siteURL = 'siteURL'
try
{
    write-host -foregroundcolor cyan $Sitename "Creating Default Association Groups......"
    $web = Get-SPWeb $siteUrl;
    # this symbol i:0#.w is presenting windows authentication security mechanism
    $owner1 = $web.EnsureUser('domain\username')
    $owner2 = $web.EnsureUser('domain\username')
    $web.CreateDefaultAssociatedGroups($owner1,$owner2,$siteName);
    $web.Title = 'DesiredTitle'
    $web.Update()
    write-host -foregroundcolor green $Sitename "Successfully created default association groups!"
}
catch [System.Exception]
{
    write-host $Sitename "Default association groups creation failed."

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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