Using PowerShell

  • Published on
    11-Apr-2015

  • View
    27

  • Download
    0

Embed Size (px)

DESCRIPTION

how to use powershell

Transcript

Module 9: Using Operations Manager 2007 Command ShellTable of Contents Module Overview 1 Lesson 1: Command Shell Overview 2 Start a PowerShell command prompt 6 Run common PowerShell commands 6 Lesson 2: Using Command Shell with Operations Manager 2007 7 Lab: Using the Command Shell 31

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, email addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. 2007 Microsoft Corporation. All rights reserved. Microsoft are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

Version 1.2

Module 9: Using Operations Manager 2007 Command Shell

1

Module Overview

Most administrators have become comfortable with the graphical user interface. Having the ability to point and click to perform actions is much easier for most administrators. However, there are times when using the command line to perform an action is more efficient. Putting commands into scripts to automate administrative tasks can also save time for administrators.

ObjectivesAfter completing this module, you will be able to: Identify how the command shell is used Understand the cmdlets that are included with Operations Manager 2007

2

Module 9: Using Operations Manager 2007 Command Shell

Lesson 1: Command Shell Overview

The Command Shell provides the ability to quickly manipulate objects from a command line instead of using the GUI. Based on PowerShell, the Command Shell adds additional cmdlets that are specific to the management of Operations Manager.

ObjectivesAfter completing this lesson, you will be able to: Understand the basics of PowerShell Understand how the Command Shell is incorporated into PowerShell

Module 9: Using Operations Manager 2007 Command Shell

3

What is the Command Shell?

The Operations Manager Command Shell is based on PowerShell. PowerShell is a command line based administrative tool that is used with many Microsoft products. PowerShell itself is actually a framework for cmdlets. There are some cmdlets that are available when PowerShell is installed on a system, but the real power behind PowerShell comes from the fact that it is extensible. The entire command set is not included in the PowerShell installation. Instead, applications that are PowerShell capable have their own set of cmdlets. PowerShell becomes the command center for running the cmdlets. Administrators only need to have the cmdlets that are required for the services within their organization. Commands that are issued through the GUI are also available from the Command Shell. If certain actions are performed by administrators on a regular basis, the command can be scripted and scheduled to run instead of having an administrator manually execute the command. Te review the set of cmdlets that are available, issue the get-command cmdlet. This will return all of the cmdlets that are available for use. When PowerShell is initially installed, you will see the list of cmdlets that are natively available. Once Operations Manager is installed, the cmdlets that are specific to Operations Manager will appear in the list.

4

Module 9: Using Operations Manager 2007 Command Shell

Getting HelpTo see how a cmdlet is used and its functions, the get-help cmdlet can be used. To view how to use the get-command cmdlet, issue the command get-help get-command. The results will contain a summary of the options that are available when using the cmdlet. To see more information, two options are available, -detailed and -full. Using detailed will return more options that are available when using the cmdlet and full will present the entire set of documentation that is available for the cmdlet.

Format of a cmdletCmdlets follow a verb-noun syntax. The verb part of the command specifies the action that will be performed and the noun is the object that will be affected. The get-help cmdlet is used to retrieve the help information on an object. The start-service cmdlet is used to stop (verb) a service (noun) on the system.

AliasingAliases can be used instead of typing a long cmdlet. Aliases help streamline the use of cmdlets, making them more efficient when an administrator wants to type a command quickly. To view an alias for a cmdlet, use the get-alias cmdlet. To view the alias for the set-location cmdlet, type get-alias set-location.

Installing the Command Shell

Module 9: Using Operations Manager 2007 Command Shell

5

The Command Shell can be installed separately from the Operations Console. If an administrator wants to run the Command Shell from a workstation, the only requirement is that PowerShell is installed before the Command Shell. Of course the prerequisites for PowerShell must be met, but the administrator does not have to load any other components of Operations Manager to run cmdlets from the workstation.For more information about PowerShell, visit the Windows PowerShell Technology Center at http://www.microsoft.com/windowsserver2003/technologies/management/powershe ll/default.mspx

Practice: Running cmdlets

This practice is meant to introduce you to PowerShell and some of the cmdlets that are available when it is installed.

ObjectivesIn this practice, you will: Open the PowerShell command line interface. Issue common PowerShell commands.

6

Module 9: Using Operations Manager 2007 Command Shell

Instructions Start the DC1 virtual machine After DC1 is running, start the OpsMgrSQL virtual machine After OpsMgrSQL is running, start the CHI-RMS virtual machine

Start a PowerShell command prompt1. Log in as SOmelc on CHI-RMS 2. Select Start > All Programs > System Center Operations Manager 2007 > Command Shell 3. Verify that you are connected to CHI-RMS

Run common PowerShell commands1. At the command prompt enter get-help and press enter 2. Review the help information 3. At the command prompt enter get-help get-command 4. Review the help information about the get-command command 5. At the command prompt enter get-help get-command detailed 6. Review the help information about the get-command command 7. At the command prompt enter get-help get-command full 8. Review the help information about the get-command command

After Completing This PracticeLeave all virtual machines running, they will be used within the Lab.

Module 9: Using Operations Manager 2007 Command Shell

7

Lesson 2: Using Command Shell with Operations Manager 2007

After installing the Command Shell, you can run cmdlets interactively from the Command Shell prompt, or scripts can be created to simplify the management of some administrative tasks. Several cmdlets are available to use, and when combined with existing PowerShell cmdlets, powerful scripts can be created.

ObjectivesAfter completing this lesson, you will be able to: Understand how to use the Command Shell Identify the cmdlet available to use with the Command Shell

8

Module 9: Using Operations Manager 2007 Command Shell

Using the Command Shell

Even though the Command Shell is based on PowerShell, the commands that are used with the Operations Manager are not available until the Command Shell is started. Once the Command Shell is started, a PowerShell snap-in is loaded, making the Operations Manager cmdlets ready to use. The default management server is also contacted and all of the cmdlets will run using that management server as the target unless the target is changed. The Command Shell appears as command prompt-based window. The command line is configured to reflect the command shell use and the management server that the

Recommended

View more >