Functions
Quite often, as the usage of SQL-PowerShell increases, some efficiencies are gained by using functions. Functions are especially useful when you are creating things that are done on a regular basis either directly in the console or in a script.
For example, a long script may have been developed that contains several checks for the existence of a file, such as a long database filename, as in the following:
Using the earlier example of comparing two strings, this example writes a function named test
, so if future comparisons are required, the typing requirements will be greatly reduced.
Note
Execute the Get-Help about_function
command ...
Get Microsoft® SQL Server 2008 R2 Unleashed now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.