Simple enough, needed to create a few SharePoint groups and thought PowerShell would be the best answer.
$SiteUrl = "http://sharepointed.com/sites/a"
$Web = Get-SPWeb $SiteUrl
$description = “Super cool stuff”
$permissionLevel = “Read”
$groups = “Group A”, “Group B”, “Group C”
foreach($groupName in $groups)
{
$web.SiteGroups.Add($groupName, $web.SiteUsers[“domain\SomeUser”], $web.SiteUsers[“domain\SomeUser”], $description)
$group = $web.SiteGroups[$groupName]
$roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
$roleDefinition = $web.Site.RootWeb.RoleDefinitions[$permissionLevel]
$roleAssignment.RoleDefinitionBindings.Add($roleDefinition)
$web.RoleAssignments.Add($roleAssignment)
$web.Update()
}
$web.SiteGroups.Add(name, owner, default user, description)
Parameters
name
Type: System.String
A string that represents the new group name.
owner
Type: Microsoft.SharePoint.SPMember
An SPMember object that specifies the owner.
defaultUser
Type: Microsoft.SharePoint.SPUser
An SPUser object that specifies the default user for the group.
description
Type: System.String
A string that contains a description for the group.
More details:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spgroupcollection.add.aspx
To get all the uses / groups from a site or web see this post:
http://www.sharepointed.com/2016/10/17/get-all-groups-and-users-in-a-site-collection-or-web/