New-SPUser
Applies to: SharePoint Server 2010, SharePoint Foundation 2010
Topic Last Modified: 2011-07-19
Adds an existing user to a SharePoint site with the designated permissions.
New-SPUser [-UserAlias] <String> -Web <SPWebPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-DisplayName <String>] [-Email <String>] [-Group <SPGroupPipeBind>] [-MobileNumber <String>] [-PermissionLevel <String[]>] [-SiteCollectionAdmin <SwitchParameter>] [-WhatIf [<SwitchParameter>]]
The New-SPUser cmdlet adds an existing user to a SharePoint Web site with the designated permissions. This user has the given permissions in all subsites that inherit permissions. The user account must already exist in the user directory.
If your environment is in Active Directory mode, the user must already exist in Active Directory Domain Services (AD DS) and only the UserAlias parameter is required; all other fields are pulled from AD DS. If only an alias is given and the farm is in Active Directory Account Create mode, the Email parameter is also required.
| Parameter | Required | Type | Description | ||
|---|---|---|---|---|---|
| UserAlias | Required | System.String | |||
| Web | Required | Microsoft.SharePoint.PowerShell.SPWebPipeBind | Specifies the URL or GUID of the Web on which to create this user. The type must be a valid URL, in the form http://server_name, or a GUID, in the form 1234-5678-9876-0987. | ||
| AssignmentCollection | Optional | Microsoft.SharePoint.PowerShell.SPAssignmentCollection | Manages objects for the purpose of proper disposal. Use of objects, such as SPWeb or SPSite, can use large amounts of memory and use of these objects in Windows PowerShell scripts requires proper memory management. Using the SPAssignment object, you can assign objects to a variable and dispose of the objects after they are needed to free up memory. When SPWeb, SPSite, or SPSiteAdministration objects are used, the objects are automatically disposed of if an assignment collection or the Global parameter is not used.
| ||
| Confirm | Optional | System.Management.Automation.SwitchParameter | Prompts you for confirmation before executing the command. For more information, type the following command: get-help about_commonparameters | ||
| DisplayName | Optional | System.String | Specifies a string that contains the display name of the user. The type must be a valid user name; for example, Joe. | ||
| | Optional | System.String | Specifies the e-mail address of the new user. The type must be a valid e-mail address, in the form someone@example.com. | ||
| Group | Optional | Microsoft.SharePoint.PowerShell.SPGroupPipeBind | Specifies the user group to which the new user belongs. | ||
| MobileNumber | Optional | System.String | Specifies the user e-mail address of the new user. The type must be a valid e-mail address, in the form someone@example.com. | ||
| PermissionLevel | Optional | System.String[] | Adds a user to a permission level. The type must be a valid permission level for the Web application; for example, Full Control, Read, Contribute, or All. | ||
| SiteCollectionAdmin | Optional | System.Management.Automation.SwitchParameter | Specifies whether to add the user as an administrator to the site collection. | ||
| WhatIf | Optional | System.Management.Automation.SwitchParameter | Displays a message that describes the effect of the command instead of executing the command. For more information, type the following command: get-help about_commonparameters |
------------------EXAMPLE 1----------------------
PS> New-SPUser - UserAlias 'Contoso\Jdoe'-displayname 'John Doe' -web http://contoso.com
This example adds a new user named John Doe to the Contoso domain.
------------------EXAMPLE 2----------------------
Get-SPWeb http://sitename | New-SPUser -UserAlias Contoso\Jdoe
This example adds Contoso\Jdoe to all Webs in the http://sitename site collection. Because this site collection uses inherited permissions, only the top-level Web site needs to be touched.

Note