< Back

Get-DbaModule

Mon Jan 13, 2020 11:17 am

NAME Get-DbaModule



SYNOPSIS

Displays all objects in sys.sys_modules after specified modification date. Works on SQL Server 2008 and above.





SYNTAX

Get-DbaModule [[-SqlInstance] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-SqlCredential]

<Pscredential>] [[-Database] <System.Object[]>] [[-ExcludeDatabase] <System.Object[]>] [[-ModifiedSince]

<Datetime>] [[-Type] <System.String[]>] [-ExcludeSystemDatabases <Switch>] [-ExcludeSystemObjects <Switch>]

[[-InputObject] <Microsoft.SqlServer.Management.Smo.Database[]>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Quickly find modules (Stored Procs, Functions, Views, Constraints, Rules, Triggers, etc) that have been modified

in a database, or across all databases.



Results will exclude the module definition, but can be queried explicitly.





PARAMETERS

-Database [<System.Object[]>]

The database(s) to process. If unspecified, all databases will be processed.



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



-ExcludeDatabase [<System.Object[]>]

The database(s) to exclude.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ExcludeSystemDatabases [<Switch>]

Allows you to suppress output on system databases



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ExcludeSystemObjects [<Switch>]

Allows you to suppress output on system objects



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<Microsoft.SqlServer.Management.Smo.Database[]>]

Enables piping from Get-DbaDatabase.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-ModifiedSince [<Datetime>]

DateTime value to use as minimum modified date of module.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlCredential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-SqlInstance [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The target SQL Server instance or instances.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Type [<System.String[]>]

Limit by specific type of module. Valid choices include: View, TableValuedFunction, DefaultConstraint,

StoredProcedure, Rule, InlineTableValuedFunction, Trigger, ScalarFunction



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: StoredProcedure, Trigger

Author: Brandon Abshire, 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:\\>Get-DbaModule -SqlInstance sql2008, sqlserver2012



Return all modules for servers sql2008 and sqlserver2012 sorted by Database, Modify_Date ASC.

-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Get-DbaModule -SqlInstance sql2008, sqlserver2012 | Select-Object *



Shows hidden definition column (informative wall of text).

-------------------------- EXAMPLE 3 --------------------------



PS C:\\>Get-DbaModule -SqlInstance sql2008 -Database TestDB -ModifiedSince "2017-01-01 10:00:00"



Return all modules on server sql2008 for only the TestDB database with a modified date after 1 January 2017

10:00:00 AM.

-------------------------- EXAMPLE 4 --------------------------



PS C:\\>Get-DbaModule -SqlInstance sql2008 -Type View, Trigger, ScalarFunction



Return all modules on server sql2008 for all databases that are triggers, views or scalar functions.

-------------------------- EXAMPLE 5 --------------------------



PS C:\\>'sql2008' | Get-DbaModule -Database TestDB -Type View, StoredProcedure, ScalarFunction



Return all modules on server sql2008 for only the TestDB database that are stored procedures, views or scalar

functions. Input via Pipeline

-------------------------- EXAMPLE 6 --------------------------



PS C:\\>Get-DbaDatabase -SqlInstance sql2008 -ExcludeSystem | Get-DbaModule -Type View, Trigger, ScalarFunction



Return all modules on server sql2008 for all user databases that are triggers, views or scalar functions.

-------------------------- EXAMPLE 7 --------------------------



PS C:\\>Get-DbaDatabase -SqlInstance sql2008, sqlserver2012 -ExcludeUser | Get-DbaModule -Type StoredProcedure

-ExcludeSystemObjects



Return all user created stored procedures in the system databases for servers sql2008 and sqlserver2012.



RELATED LINKS

https://dbatools.io/Get-DbaModule