Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
PowerShell for SQL Server Essentials

You're reading from   PowerShell for SQL Server Essentials Manage and monitor SQL Server administration and application deployment with PowerShell

Arrow left icon
Product type Paperback
Published in Feb 2015
Publisher Packt
ISBN-13 9781784391492
Length 186 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Donabel Santos Donabel Santos
Author Profile Icon Donabel Santos
Donabel Santos
Arrow right icon
View More author details
Toc

Table of Contents (9) Chapters Close

Preface 1. Getting Started with PowerShell FREE CHAPTER 2. Using PowerShell with SQL Server 3. Profiling and Configuring SQL Server 4. Basic SQL Server Administration 5. Querying SQL Server with PowerShell 6. Monitoring and Automating SQL Server A. Implementing Reusability with Functions and Modules Index

Getting help

PowerShell used to come bundled with help documentation. If you've worked with *nix systems, it's similar to the man page.

Starting with PowerShell v3, however, the help files/system were not installed with PowerShell. One of the chronic problems with a help system that comes bundled with an application is that the contents get outdated right away. Applications are continuously being patched, improved, and changed, and thus the documentation needs to be updated. You will need to consciously download and install the help files when you are ready.

Once ready, run PowerShell as an administrator and just type in the following command:

Update-Help

This will connect you to a Microsoft server to download the most recent version of PowerShell help:

Getting help

When you need to look for syntaxes or examples from the help system, you can use Get-Help and then the cmdlet name. For example, if you want to get ChildItem, you can use the following command:

Get-Help Get-ChildItem

Other switches available for Get-Help that you might find useful are as follows:

  • Get-Help Get-ChildItem -Detailed
  • Get-Help Get-ChildItem -Examples
  • Get-Help Get-ChildItem -Full

Note

Get-Help can also be simply referred to as help.

Sometimes you may prefer to open the local help system in a different window, in which case you can use the following command:

Get-Help Get-ChildItem -ShowWindow

The result is shown in the following screenshot:

Getting help

Having the help document in a different window allows you to do simultaneous tasks, that is, write your script and refer to the syntaxes and examples. The help window also allows for searching and highlighting keywords.

If what you prefer is to view the help online and get the most recent version to date, you can use the following command instead:

Get-Help Get-ChildItem -Online

This will open the corresponding Microsoft TechNet entry in your default browser:

Getting help

Getting help from other cmdlets

In addition to Get-Help, there are two other trusty cmdlets you should know if you want to know PowerShell a lot better. If you need to use a command but only remember the name or part of the name or if you want to get a list of commands based on parameters, you can use Get-Command. For example, as introduced earlier in the chapter, you can get log-related cmdlets using the following command:

Get-Command –Name "*Log*"

If you need to know what properties and methods are available for an object—for example, a variable or the result returned by a cmdlet—you can use Get-Member, as shown in the following example:

$message = "Hello World!"
$message | Get-Member

Since a message is a string, the preceding snippet returns all the properties and methods supported for a string data type.

Two risk-mitigation parameters that you should also get acquainted with are -WhatIf and -Confirm. You can add these two parameters to most cmdlets, and they can help you avoid really stressful "oops" situations.

The -WhatIf parameter describes the effect of a command instead of executing it. The -Confirm parameter forces a prompt before executing the command. It pays to be careful before you run scripts in your environment. It pays to be extra careful; as much as possible, test your scripts in a test environment first.

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You have been reading a chapter from
PowerShell for SQL Server Essentials
Published in: Feb 2015
Publisher: Packt
ISBN-13: 9781784391492
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image