commands

^

Add-DbaExtendedProperty

Author Chrissy LeMaire (@cl), netnerds.net
Availability Windows, Linux, macOS

 

Synopsis

Adds an extended property

Description

Adds an extended property

This command works out of the box with databases but you can add extended properties from several different types of objects, including:

Aggregate Assembly Column Constraint Contract Database Event Notification Filegroup Function Index Logical File Name Message Type Parameter Partition Function Partition Scheme Procedure Queue Remote Service Binding Route Rule Schema Service Synonym Table Trigger Type View Xml Schema Collection

Syntax

Add-DbaExtendedProperty
    [[-SqlInstance] <DbaInstanceParameter[]>]
    [[-SqlCredential] <PSCredential>]
    [[-Database] <String[]>]
    [-Name] <String>
    [-Value] <String>
    [[-InputObject] <PSObject[]>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Add-DbaExtendedProperty -SqlInstance sql2016

Gets all extended properties on all databases

Example: 2
PS C:\> Add-DbaExtendedProperty -SqlInstance Server1 -Database db1

Gets the extended properties for the db1 database

Example: 3
PS C:\> Add-DbaExtendedProperty -SqlInstance Server1 -Database db1 -Name version -Value "1.0.0"

Sets the version extended property for the db1 database to 1.0.0

Example: 4
PS C:\> Get-DbaDbStoredProcedure -SqlInstance localhost -Database tempdb | Add-DbaExtendedProperty -Name SPVersion -Value 10.2

Creates an extended property for all stored procedures in the tempdb database named SPVersion with a value of 10.2

Example: 5
PS C:\> Get-DbaDbTable -SqlInstance localhost -Database mydb -Table mytable | Add-DbaExtendedProperty -Name MyExtendedProperty -Value "This is a test"

Creates an extended property named MyExtendedProperty for the mytable table in the mydb, with a value of "This is a test"

Required Parameters

-Name

The name of the extended property

Alias Property
Required True
Pipeline false
Default Value
-Value

The value for the extended property

Alias
Required True
Pipeline false
Default Value

Optional Parameters

-SqlInstance

The target SQL Server instance

Alias
Required False
Pipeline false
Default Value
-SqlCredential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-Database

Add an extended property to a specific database

Alias
Required False
Pipeline false
Default Value
-InputObject

Enables piping from Get-Dba* commands

Alias
Required False
Pipeline true (ByValue)
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False
-WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

Alias wi
Required False
Pipeline false
Default Value
-Confirm

Prompts you for confirmation before executing any changing operations within the command.

Alias cf
Required False
Pipeline false
Default Value

 

Want to see the source code for this command? Check out Add-DbaExtendedProperty on GitHub.
Want to see the Bill Of Health for this command? Check out Add-DbaExtendedProperty.