Listing user-defined assemblies
In this recipe, we will list the user-defined assemblies in a SQL Server database.
Getting ready
We can use the SampleDB
database that we used in the previous recipe, or you can substitute this with any database that is accessible to you that has some user-defined assemblies.
How to do it...
These are the steps to list user-defined assemblies:
Open the PowerShell console application by going to Start | Accessories | Windows PowerShell | Windows PowerShell ISE.
Import the SQLPS module as follows:
#import SQL Server module Import-Module SQLPS -DisableNameChecking
Add the following script and run:
$instanceName = "KERRIGAN" $server = New-Object ` -TypeName Microsoft.SqlServer.Management.Smo.Server ` -ArgumentList $instanceName $databaseName = "SampleDB" $database = $server.Databases[$databaseName] #list assemblies except system assemblies #using PowerShell V3 syntax $database.Assemblies | Where-Object IsSystemObject -eq $false
How it works...
Listing user-defined assemblies...