Solved

How to use this powershell script?

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
A procedure for exporting installed hotfix details of remote computers using powershell
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Edureka is one of the fastest growing and most effective online learning sites.  We are here to help you succeed.

912 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now