Add-SPShellAdmin

向指定数据库的 SharePoint_Shell_Access 角色添加用户。

语法

Add-SPShellAdmin
   [-UserName] <String>
   [-AssignmentCollection <SPAssignmentCollection>]
   [-Confirm]
   [-Database <SPDatabasePipeBind>]
   [-WhatIf]
   [<CommonParameters>]

说明

在运行此 cmdlet 以将用户添加到 SharePoint_Shell_Access 角色中时,您必须拥有 SQL Server 实例上 securityadmin 固定服务器角色和所有受影响数据库上 db_owner 固定服务器角色中的成员身份,并且在本地计算机上必须拥有本地管理权限。

This cmdlet is intended only to be used with a database that uses Windows authentication. There is no need to use this cmdlet for databases that use SQL authentication; in fact, doing so may result in an error message.

按照以下操作,使用 Add-SPShellAdmin cmdlet 将用户添加到 SharePoint_Shell_Access 角色中:

--如果您仅指定用户,用户将添加到服务器场配置数据库的角色中。

--If you use the database parameter, the user is added to the role on the farm configuration database, the Central Administration content database, and the specified database. Using the database parameter is the preferred method because most of the administrative operations require access to the Central Administration content database.

The user is added to the WSS_Admin_WPG group on all Web servers when the user is added to the SharePoint_Shell_Access role. If the target database does not have a SharePoint_Shell_Access role, the role is automatically created.

若要对 SharePoint 产品使用Windows PowerShell,用户必须是配置数据库上SharePoint_Shell_Access角色的成员,以及安装 SharePoint 产品的计算机上WSS_ADMIN_WPG本地组的成员。

但是,运行此 cmdlet 的结果是,使用 UserName 参数指定的用户将具有 SPDataAccess 角色(如果存在)或db_owner角色(如果 SPDataAccess 角色不存在)在受影响的数据库上,如上所述。 因此,您应该仔细规划向哪些用户授予此访问权限。

因此,您应该仔细规划向哪些用户授予此访问权限。

有关适用于 SharePoint 产品的 Windows PowerShell 的权限和最新信息,请参阅 https://go.microsoft.com/fwlink/p/?LinkId=251831 上的联机文档。

示例

-------------------示例 1-------------------------

Add-SPShellAdmin -UserName CONTOSO\User1

此示例将名为 User1 的新用户仅添加到服务器场配置数据库中的 SharePoint_Shell_Access 角色,同时确保将该用户添加到服务器场的每台服务器上的 WSS_Admin_WPG 本地组。

-------------------示例 2-------------------------

Add-SPShellAdmin -UserName CONTOSO\User1 -database 4251d855-3c15-4501-8dd1-98f960359fa6

此示例通过将数据库 GUID 传递到 cmdlet,从而将名为 User1 的新用户同时添加到指定内容数据库和配置数据库的 SharePoint_Shell_Access 角色中。

-------------------示例 3-------------------------

Get-SPDatabase | Where-Object {$_.WebApplication -like "SPAdministrationWebApplication"} | Add-SPShellAdmin CONTOSO\User1

此示例将名为 User1 的新用户同时添加到指定管理中心内容数据库和配置数据库的 SharePoint_Shell_Access 角色。

-------------------示例 4-------------------------

Get-SPDatabase | ?{$_.Name -eq "WSS_Content"} | Add-SPShellAdmin -Username CONTOSO\User1

此示例通过将数据库名称传递到 cmdlet,从而将名为 User1 的新用户同时添加到指定内容数据库和配置数据库的 SharePoint_Shell_Access 角色中。

参数

-Confirm

执行命令前,看到确认提示。 有关详细信息,请键入以下命令:get-help about_commonparameters

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-Database

Specifies the GUID of the database or the Database object that includes the SharePoint_Shell_Access role to which you want to add the user. If the database parameter is not specified, the configuration database is used. The farm configuration database is always included, even if you specify another database.

Type:SPDatabasePipeBind
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-UserName

指定要添加到目标数据库的 SharePoint_Shell_Access 角色的用户名。

Type:String
Position:1
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-WhatIf

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

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition

-工作分配

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.

When the Global parameter is used, all objects are contained in the global store. If objects are not immediately used, or disposed of by using the Stop-SPAssignment command, an out-of-memory scenario can occur.

Type:SPAssignmentCollection
Position:Named
Default value:None
Accept pipeline input:True
Accept wildcard characters:False
Applies to:SharePoint Server Subscription Edition