Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By : Donabel Santos
Book Image

SQL Server 2014 with PowerShell v5 Cookbook

By: Donabel Santos

Overview of this book

Table of Contents (21 chapters)
SQL Server 2014 with PowerShell v5 Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Documenting PowerShell script for Get-Help


In this recipe, we will take a look at how to use header comments in your script. Formatting the header comments in a specific way will enable them to be utilized by the Get-Help cmdlet.

How to do it...

In this recipe, we will explore the comment-based help:

  1. Open PowerShell ISE as an administrator.

  2. Add the following script:

    <#
    .SYNOPSIS
       Creates a full database backup
    .DESCRIPTION
       Creates a full database backup using specified instance name and database name
       This will place the backup file to the default backup directory of the instance
    .PARAMETER instanceName
       instance where database to be backed up resides
    .PARAMETER databaseName
       database to be backed up
    .EXAMPLE
       PS C:\PowerShell> .\Backup-Database.ps1 -instanceName "QUERYWORKS\SQL01" -databaseName "pubs"
    .EXAMPLE
       PS C:\PowerShell> .\Backup-Database.ps1 -instance "QUERYWORKS\SQL01" -database "pubs"
    .NOTES
    
       To get help:
       Get-Help .\Backup-Database.ps1
    
    #>
    
    param
    ...