Solved

How to use this powershell script?

Posted on 2012-03-20
2
623 Views
Last Modified: 2012-03-21
I would like to create security groups on SharePoint 2010 using powershell. I found this script http://sharepointryan.com/2011/07/20/create-sharepoint-groups-using-powershell/ but since I am new to powershell I don't really know how to use it. Can somebody walk me through it?
0
Comment
Question by:MisUszatek
2 Comments
 
LVL 3

Assisted Solution

by:Sherif_Talaat
Sherif_Talaat earned 75 total points
ID: 37746757
This script create a PowerShell function called "New-SPGroup" that accept the following parameters:

- SharePoint Web URL
- Group Name
- Group Owner
- Member Name
- Description

In order to use this method, you can simply execute this script to create a new PowerShell called "New-SPGroup" in your runspace, then use it to create the groups you want like the example below:

New-SPGroup -Web http://intranet -GroupName "Test Group" -OwnerName DOMAIN\User -MemberName DOMAIN\User2 -Description "My Group"
0
 
LVL 38

Accepted Solution

by:
Justin Smith earned 275 total points
ID: 37746760
Copy this to a text doc and save it as CreateGroups.ps1 (you can name it whatever you want).

Bring up SharePoint Management Console and navigate to the folder that contains the script.  You have to "dot source" the file to make the function available to use.  Type . .\CreateGroups.ps1 and hit enter.  

Now you can use the New-SPGroup commandlet.  For example....

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.
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to sign a powershell script so you can prevent tampering, and only allow users to run authorised Powershell scripts
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question