commands

^

Get-DbaDependency

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

 

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

Synopsis

Finds object dependencies and their relevant creation scripts.

Description

This function recursively finds all objects that depends on the input.
It will then retrieve rich information from them, including their creation scripts and the order in which it should be applied.

By using the 'Parents' switch, the function will instead retrieve all items that the input depends on (including their creation scripts).

For more details on dependency, see:
https://technet.microsoft.com/en-us/library/ms345449(v=sql.105).aspx

Syntax

Get-DbaDependency
    [[-InputObject] <Object>]
    [-AllowSystemObjects]
    [-Parents]
    [-IncludeSelf]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> $table = (Get-DbaDatabase -SqlInstance sql2012 -Database Northwind).tables | Where-Object Name -eq Customers
PS C:\> $table | Get-DbaDependency

Returns everything that depends on the "Customers" table

Optional Parameters

-InputObject

The SMO object to parse

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

Normally, system objects are ignored by this function as dependencies.
This switch overrides that behavior.

Alias
Required False
Pipeline false
Default Value False
-Parents

Causes the function to retrieve all objects that the input depends on, rather than retrieving everything that depends on the input.

Alias
Required False
Pipeline false
Default Value False
-IncludeSelf

Includes the object whose dependencies are retrieves itself.
Useful when exporting an entire logic structure in order to recreate it in another database.

Alias
Required False
Pipeline false
Default Value False
-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