< Back
Get-DbaDependency
Post
NAME Get-DbaDependency
SYNOPSIS
Finds object dependencies and their relevant creation scripts.
SYNTAX
Get-DbaDependency [[-InputObject] <System.Object>] [-AllowSystemObjects <Switch>] [-Parents <Switch>]
[-IncludeSelf <Switch>] [-EnableException <Switch>] [<CommonParameters>]
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/lib ... .105).aspx
PARAMETERS
-AllowSystemObjects [<Switch>]
Normally, system objects are ignored by this function as dependencies.
This switch overrides that behavior.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-IncludeSelf [<Switch>]
Includes the object whose dependencies are retrieves itself.
Useful when exporting an entire logic structure in order to recreate it in another database.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-InputObject [<System.Object>]
The SMO object to parse
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Parents [<Switch>]
Causes the function to retrieve all objects that the input depends on, rather than retrieving everything that
depends on the input.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Database, Dependent, Dependency, Object
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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
RELATED LINKS
https://dbatools.io/Get-DbaDependency
SYNOPSIS
Finds object dependencies and their relevant creation scripts.
SYNTAX
Get-DbaDependency [[-InputObject] <System.Object>] [-AllowSystemObjects <Switch>] [-Parents <Switch>]
[-IncludeSelf <Switch>] [-EnableException <Switch>] [<CommonParameters>]
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/lib ... .105).aspx
PARAMETERS
-AllowSystemObjects [<Switch>]
Normally, system objects are ignored by this function as dependencies.
This switch overrides that behavior.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
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.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-IncludeSelf [<Switch>]
Includes the object whose dependencies are retrieves itself.
Useful when exporting an entire logic structure in order to recreate it in another database.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-InputObject [<System.Object>]
The SMO object to parse
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Parents [<Switch>]
Causes the function to retrieve all objects that the input depends on, rather than retrieving everything that
depends on the input.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: Database, Dependent, Dependency, Object
Author: Chrissy LeMaire (@cl), netnerds.net
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- 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
RELATED LINKS
https://dbatools.io/Get-DbaDependency