Solved

How to use this powershell script?

Posted on 2012-03-20
2
628 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

A brief introduction to what I consider to be the best editor for PowerShell.
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

820 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