Try below:
http://ift.tt/1qC0Aki
function New-SPGroup {
<#
.Synopsis
Use New-SPGroup to create a SharePoint Group.
.Description
This function uses the Add() method of a SharePoint RoleAssignments property in an SPWeb to create a SharePoint Group.
.Example
C:\PS>New-SPGroup -Web http://intranet -GroupName "Test Group" -OwnerName DOMAIN\User -MemberName DOMAIN\User2 -Description "My Group"
This example creates a group called "Test Group" in the http://intranet site, with a description of "My Group". The owner is DOMAIN\User and the first member of the group is DOMAIN\User2.
.Notes
Name: New-SPGroup
Author: Ryan Dennis
Last Edit: July 18th 2011
Keywords: New-SPGroup
.Link
http://ift.tt/1qQKgyf
http://ift.tt/1qC0Boi
.Inputs
None
.Outputs
None
#Requires -Version 2.0
#>
[CmdletBinding()]
Param(
[Microsoft.SharePoint.PowerShell.SPWebPipeBind]$Web,
[string]$GroupName,
[string]$OwnerName,
[string]$MemberName,
[string]$Description
)
$SPWeb = $Web.Read()
if ($SPWeb.SiteGroups[$GroupName] -ne $null){
throw "Group $GroupName already exists!"
}
if ($SPWeb.Site.WebApplication.UseClaimsAuthentication){
$op = New-SPClaimsPrincipal $OwnerName -IdentityType WindowsSamAccountName
$mp = New-SPClaimsPrincipal $MemberName -IdentityType WindowsSamAccountName
$owner = $SPWeb | Get-SPUser $op
$member = $SPWeb | Get-SPUser $mp
}
else {
$owner = $SPWeb | Get-SPUser $OwnerName
$member = $SPWeb | Get-SPUser $MemberName
}
$SPWeb.SiteGroups.Add($GroupName, $owner, $member, $Description)
$SPGroup = $SPWeb.SiteGroups[$GroupName]
$SPWeb.RoleAssignments.Add($SPGroup)
$SPWeb.Dispose()
return $SPGroup
}
Also check
http://ift.tt/1qQKgyj
http://ift.tt/1qQKdmc
If this helped you resolve your issue, please mark it Answered
No comments:
Post a Comment