Set-SqlDatabasePermission

Sets database level permissions.

Syntax

Set-SqlDatabasePermission [[-sqlserver] <Object>] [-dbname] <Object> [-permission] {Alter | AlterAnyAsymmetricKey | AlterAnyApplicationRole | AlterAnyAssembly | AlterAnyCertificate | AlterAnyDataspace | AlterAnyDatabaseEventNotification | AlterAnyFulltextCatalog | AlterAnyMessageType | AlterAnyRole | AlterAnyRoute | AlterAnyRemoteServiceBinding | AlterAnyContract | AlterAnySymmetricKey | AlterAnySchema | AlterAnyService | AlterAnyDatabaseDdlTrigger | AlterAnyUser | Authenticate | BackupDatabase | BackupLog | Control | Connect | ConnectReplication | Checkpoint | CreateAggregate | CreateAsymmetricKey | CreateAssembly | CreateCertificate | CreateDatabase | CreateDefault | CreateDatabaseDdlEventNotification | CreateFunction | CreateFulltextCatalog | CreateMessageType | CreateProcedure | CreateQueue | CreateRole | CreateRoute | CreateRule | CreateRemoteServiceBinding | CreateContract | CreateSymmetricKey | CreateSchema | CreateSynonym | CreateService | CreateTable | CreateType | CreateView | CreateXmlSchemaCollection | Delete | Execute | Insert | References | Select | Showplan | SubscribeQueryNotifications | TakeOwnership | Update | ViewDefinition | ViewDatabaseState | AlterAnyDatabaseAudit} [-name] <String> [-action] <String> [<CommonParameters>]

Detailed Description

The Set-SqlDatabasePermission function sets database level permissions.

Related Commands

* Set-SqlDatabasePermission

Parameters

Name Description Required? Pipeline Input Default Value
sqlserver    false  false   
dbname    true  false   
permission    true  false   
name    true  false   
action    true  false   

Input Type

None You cannot pipe objects to Set-SqlDatabasePermission

Return Values

None This function does not generate any output.

Examples

EXAMPLE 1

Set-SqlDatabasePermission -sqlserver "Z002\sql2k8" -dbname $database -permission "ViewDefinition" -name "TestPSUnit" -action "Grant"
This command grants ViewDefinition permission to the TestPSUnit user.

EXAMPLE 2

$database = Get-SqlDatabase "Z002\sql2k8" "pubs"
Set-SqlDatabasePermission -dbname $database -permission "ViewDefinition" -name "TestPSUnit" -action "Grant"
This command grants ViewDefinition permission to the TestPSUnit user.