04.07.2013 Views

Windows PowerShell 3.0 Step by Step - Cdn.oreilly.com - O'Reilly

Windows PowerShell 3.0 Step by Step - Cdn.oreilly.com - O'Reilly

Windows PowerShell 3.0 Step by Step - Cdn.oreilly.com - O'Reilly

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Getting tired of typing Get-Help all the time? After all, it is eight characters long. The solution is to<br />

create an alias to the Get-Help cmdlet. An alias is a shortcut keystroke <strong>com</strong>bination that will launch a<br />

program or cmdlet when typed. In the “Creating an alias for the Get-Help cmdlet” procedure, you will<br />

assign the Get-Help cmdlet to the G+H key <strong>com</strong>bination.<br />

note When creating an alias for a cmdlet, confirm it does not already have an alias <strong>by</strong><br />

using Get-Alias. Use New-Alias to assign the cmdlet to a unique keystroke <strong>com</strong>bination.<br />

Creating an alias for the Get-Help cmdlet<br />

1. Open <strong>Windows</strong> <strong>PowerShell</strong> <strong>by</strong> choosing Start | Run | <strong>Windows</strong> <strong>PowerShell</strong>. The <strong>PowerShell</strong><br />

prompt will open <strong>by</strong> default at the root of your Documents folder.<br />

2. Retrieve an alphabetic listing of all currently defined aliases, and inspect the list for one<br />

assigned to either the Get-Help cmdlet or the keystroke <strong>com</strong>bination G+H. The <strong>com</strong>mand to<br />

do this is as follows:<br />

Get-Alias sort<br />

3. After you have determined that there is no alias for the Get-Help cmdlet and that none is<br />

assigned to the G+H keystroke <strong>com</strong>bination, review the syntax for the New-Alias cmdlet. Use<br />

the -full argument to the Get-Help cmdlet. This is shown here:<br />

Get-Help New-Alias -full<br />

4. Use the New-Alias cmdlet to assign the G+H keystroke <strong>com</strong>bination to the Get-Help cmdlet.<br />

To do this, use the following <strong>com</strong>mand:<br />

New-Alias gh Get-Help<br />

Exploring <strong>com</strong>mands: step-<strong>by</strong>-step exercises<br />

In the following exercises, you’ll explore the use of <strong>com</strong>mand-line utilities in <strong>Windows</strong> <strong>PowerShell</strong>. You<br />

will see that it is as easy to use <strong>com</strong>mand-line utilities in <strong>Windows</strong> <strong>PowerShell</strong> as in the CMD interpreter;<br />

however, <strong>by</strong> using such <strong>com</strong>mands in <strong>Windows</strong> <strong>PowerShell</strong>, you gain access to new levels of<br />

functionality.<br />

CHAPTER 1 Overview of <strong>Windows</strong> <strong>PowerShell</strong> <strong>3.0</strong> 19

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!