Add-ExtendedProperty

Adds an extended property for a schema, table, view or column.

Syntax

Add-ExtendedProperty [-Name] <String> [-Value] <Object> [-SchemaName <String>] -ViewName <String> -ColumnName <String> [<CommonParameters>]
Add-ExtendedProperty [-Name] <String> [-Value] <Object> [-SchemaName <String>] -ViewName <String> [<CommonParameters>]
Add-ExtendedProperty [-Name] <String> [-Value] <Object> [-SchemaName <String>] -TableName <String> -ColumnName <String> [<CommonParameters>]
Add-ExtendedProperty [-Name] <String> [-Value] <Object> [-SchemaName <String>] -TableName <String> [<CommonParameters>]
Add-ExtendedProperty [-Name] <String> [-Value] <Object> [-SchemaName <String>] [<CommonParameters>]

Description

SQL Server has a special stored procedure for adding extended property metatdata about an object. Unfortunately, it has a really clunky interface. This function is an attempt to wrap sp_addextendedproperty with a saner interface.

Currently, this function only supports adding properties for schemas, tables, and columns. Submit a patch!

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
Name String

The name of the extended property to add.

true false
Value Object

The value of the extended property.

true false
SchemaName String

The schema of the object.

false false dbo
TableName String

The table name.

true false
ViewName String

The table name.

true false
ColumnName String

The column name.

true false

EXAMPLE 1

Add-ExtendedProperty -Name 'Deploy' -Value 'TRUE' -SchemaName 'spike'

Adds custom Deploy metadata for the spike schema.

EXAMPLE 2

Add-ExtendedProperty -Name 'Deploy' -Value 'TRUE' -TableName 'Food'

Adds custom Deploy metadata on the Food table in the dbo schema.

EXAMPLE 3

Add-ExtendedProperty -Name 'IsEncrypted' -Value 'FALSE' -TableName 'User' -ColumnName 'Password'

Adds custom IsEncrypted metadata on the User table's Password column.

EXAMPLE 4

Add-ExtendedProperty -Name 'ContainsPII' -Value 'FALSE' -View 'LoggedInUsers'

Demonstrates how to add custom metadata on the LoggedInUsers view

EXAMPLE 5

Add-ExtendedProperty -Name 'IsEncrypted' -Value 'FALSE' -View 'LoggedInUsers' -ColumnName 'Password'

Demonstrates how to add custom metadata for a view's column