Add-SPShellAdmin

將使用者新增至指定資料庫的 SharePoint_Shell_Access 角色。

Syntax

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

Description

當您執行此 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 角色存在,就會擁有 SPDataAccess 角色,如果 SPDataAccess 角色不存在,則會在受影響的資料庫上db_owner角色,如上所述。 因此,應該謹慎規劃可授與哪些使用者這個使用權。

因此,應該謹慎規劃可授與哪些使用者這個使用權。

如需 Windows PowerShell for SharePoint 產品的權限及最新資訊,請參閱線上文件 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 角色。

參數

-AssignmentCollection

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

-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