PowerShell Provider for SQL Server Script of the Day - Script all objects

PowerShell Provider for SQL Server Script of the Day - Script all objects

Rate This
  • Comments 1

If you're using the PowerShell provider for SQL Server, you can quickly script out all of the objects in a "directory" using a simple method. Just navigate to the directory of objects you're interested in, say the "Views" of a certain database, and type this:

# Script objects in a directory
DIR * | foreach {$_.Script()}

This will only work for objects that can be scripted, of course, and requires that you have the proper permissions.

Leave a Comment
  • Please add 6 and 1 and type the answer here:
  • Post