You are on page 1of 35

Module 9: Using Operations Manager 2007 Command Shell

Table 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

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.

Objectives
After 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

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.

Objectives
After 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

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.

Module 9: Using Operations Manager 2007 Command Shell

Getting Help
To 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 cmdlet
Cmdlets 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.

Aliasing
Aliases 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

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.

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

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 prompt


1. 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 commands


1. 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 Practice


Leave all virtual machines running, they will be used within the Lab.

Module 9: Using Operations Manager 2007 Command Shell

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.

Objectives
After 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

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 command prompt is connected to. When the command prompt appears, it displays the in the format PS Monitoring\Management_Server_Name. The PS stands for PowerShell and Monitoring denotes that the Operations Manager Command Shell snap-in is being used. If an administrators system is connected to the CHI-RMS management server, the prompt would be PS Monitoring\CHI-RMS.nwtraders.msft

Navigating the Command Shell


Two commnds exist within PowerShell that should be familiar to anyone working in a DOS environement; DIR and CD. The DIR command is used to retrieve a listing of objects within the object hierarchy, and the CD command allows the Command Shell to be focued on a specific object within the hierarchy.

Module 9: Using Operations Manager 2007 Command Shell

When using commands, PowerShell allows the TAB key to used character completion. As the command is entered, the TAB key can be pressed until the correct result is found.

Running Scripts
By default, scripts will not run within the Command Shell. This protects an organization from malicious scripts running. Since scripts will not execute, an organization does not have to worry about a rogue script performing actions within the organization This behavior may not be acceptable in all organizations. To allow scripts to execute, the setexecutionpolicy cmdlet can be used. The default setting is Restricted. Three other settings are available: AllSigned scripts must be signed with a valid certificate in order to execute RemoteSigned Scripts will run locally, but scripts that are initiated remotely will need to be signed Unrestricted All scripts can execute

Computer and Device Cmdlets

These cmdlets are used when systems are targeted for management by Operations Manager. Actions for installing, removing and working with the Operations Manager agent software and managing devices are discussed in this section.

10

Module 9: Using Operations Manager 2007 Command Shell

Get-Agent used to retrieve the Agent objects that are associated with a management server -ManagementServer specifies the management server from which to retrieve agents -Path specifies the path to the desired management groups

Install-Agent used to install the Operations Manager agent on a specified computer system -ManagementServer specifies the management server to be used by the agent -AgentManagedComputer specifies the computer(s) to install the Operations Manager agent on -InstallAgentConfiguration specifies agent configuration information -FailoverServers specifies a list of servers to be used by the agent as fail-over servers. Multiple servers should be separated by commas. -Confirm prompts for confirmation before uninstalling the agent.

Before the agent can be installed, a reference to a target computer must be obtained. This is done by executing the Start-Discovery cmdlet with an appropriate discovery object.

Uninstall-Agent used to remove the Operations Manager agent from managed systems -AgentManagedComputer specifies the computer(s) to remove the Operations Manager agent from -AgentConfiguration specifies agent configuration information -Confirm prompts for confirmation before uninstalling the agent.

Add-RemotelyManagedComputer used to add a remotely managed (agentless) computer to an Operations Manager agent -Computer specifies the remote computer(s) to manage -ProxyAgent specifies a proxy Agent object to use

Add-RemotelyManagedDevice used to add a remotely managed (agentless) device to an Operations Manager agent -Device specifies the device to manage -ProxyAgent specifies a proxy Agent object to use

Get-RemotelyManagedComputer used to retrieve the specified agentless managed computers Path specifies the management path to the remotely managed computer

Module 9: Using Operations Manager 2007 Command Shell

11

Get-RemotelyManagedDevice used to retrieve the specified agentless managed devices Path specifies the management path to the remotely managed device Remove-RemotelyManagedComputer used to remove a remotely managed (agentless) computer from an Operations Manager proxy agent -Computer specifies the computer to remove from the proxy agent -Confirm prompts to confirm removal of the remote computer.

Remove-RemotelyManagedDevice used to remove a remotely managed (agentless) device from an Operations Manager proxy agent -Device specifies the device to remove from the proxy agent -Confirm prompts to confirm removal of the remote device.

Set-ProxyAgent used to set the proxy agent for a set of remotely managed computers or devices -Computer specifies the remote computer(s) on which to change the proxy agent setting -Device specifies the remote device(s) on which to change the proxy agent setting -ProxyAgent specifies the new proxy agent for the remote computer(s) or device(s) -Confirm prompts for confirmation before assigning the proxy agent.

Get-ManagementServer - used to retrieve instances of the Management Servers for all currently connected management groups Root specifying this parameter causes the cmdlet to return only the root management server. -Path specifies the path to the management servers to retrieve.

Set-ManagementServer used to set the default Management Server for an Operations Manager agent -ManagementServer specifies the management server to be used by the agent -AgentManagedComputer specifies the agent managed computer(s) on which to change the assigned management server -FailoverServer specifies the failover server(s) for the agent(s). -GatewayManagementServer specifies the gateway management server(s) for the agent(s)

12

Module 9: Using Operations Manager 2007 Command Shell

Discovery Cmdlets

These cmdlets are used when configuring Operations Manager discovery options. New-DeviceDiscoveryConfiguration used to create a discovery criteria object based on a specified monitoring class and TCP/IP address range -MonitoringClass specifies the Operations Manager monitoring class to scan for. -FromIPAddress specifies the beginning of the TCP/IP address range to scan. -ToIPAddress specifies the ending of the TCP/IP address range to scan.

The monitoring class and address range are required parameters of this cmdlet. To view a list of the available monitoring classes, execute the cmdlet GetMonitoringClass.

New-LdapQueryDiscoveryCriteria used to create a discovery criteria object based on a Lightweight Directory Access Protocol (LDAP) query -Domain specifies the name of the domain to execute the LDAP query against. -ldapQuery specifies the LDAP query to use

Module 9: Using Operations Manager 2007 Command Shell

13

New-WindowsDiscoveryConfiguration used to create a discovery criteria object based on a set of specified computer parameters. In order to create this object, you must first create a LDAPQueryDiscoveryCriteria object using the cmdlet newldapdiscoverycriteria. -ComputerName allows you to specify which specific computers returned from the LDAP query you would like to include in the discovery results. -ComputerType allows you to specify what computer type you would like to include in the discovery results. Values include Workstation, Server, or Both. -ldapQuery allows you to pass an LDAP criteria object to the cmdlet. Used to narrow the result set returned during the discovery process. -PerformVerification specifies whether to perform a verification of the discovered system -ActionAccountCredential specifies the account credentials to use in the discovery -ManagementServer required parameter, specifies the management server that will be responsible for the computers or devices discovered -WindowsDiscoveryConfiguration specifies Windows discovery configuration objects to use in describing the computers to discover -DeviceDiscoveryConfiguration specifies device discovery configuration objects to use in describing the computers to discover

Start-Discovery used to start a task to discover computers and devices

14

Module 9: Using Operations Manager 2007 Command Shell

Management Pack Cmdlets

These cmdlets are designed for administration of Operations Manager Management Packs. They are used to list, add, remove and export Management Packs from the management group. Get-ManagementPack used to retrieve Operations Manager Management Pack(s) -Id specifies the GUID of the management pack to retrieve -Name specifies the name of the management pack to retreive

Install-ManagementPack used to install an Operations Manager Management Pack from a specified XML file -FilePath specifies the file path to the XML file for the management pack to install. Only one management pack at a time can be specified with this parameter. -Path specifies the path to the management groups into which management packs should be installed. -Confirm invokes a prompt to confirm the installation of a management pack.

Uninstall-ManagementPack used to remove installed Management Packs from the current Management Server

Module 9: Using Operations Manager 2007 Command Shell

15

-ManagementPack specifies the name of the management pack to remove. -Path specifies the path to the management groups from which management packs should be uninstalled. -Confirm invokes a prompt to confirm the removal of the management pack. -ManagementPack specifies the management pack(s) to export. -Path specifies the file system path to export the management pack(s) to

Export-ManagementPack used to export a single management pack to an XML file.

Note that this cmdlet will only export one management pack at a time. To export multiple management packs, create a set of management pack objects and use a foreach loop to export each pack individually.

Rule Cmdlets

These cmdlets are designed for managing Rules in Operations Manager. They are used to list, enable and disable rules. Get-Rule used to retrieve Operations Manager rule objects -Id used to specify the GUID of a specific rule to work with.

16

Module 9: Using Operations Manager 2007 Command Shell

-MonitoringObject when specified, only rules associated with the specified monitoring object are returned. -ManagementPack when specified, only rules associated with the specified Management Pack are returned. You can use the Get-ManagementPack cmdlet to get an appropriate argument. -Rule specifies the monitoring rule to disable -Confirm prompts for confirmation before disabling the monitoring rule. -Rule specifies the monitoring rule to enable -Confirm prompts for confirmation before enabling the monitoring rule.

Disable-Rule used to disable Operations Manager monitoring rule(s).

Enable-Rule used to enable Operations Manager monitoring rule(s)

Rules that belong to a sealed Management Pack cannot be disabled or enabled.

Task Cmdlets

These cmdlets are designed for managing Tasks in Operations Manager. They are used to list, enable and disable tasks.

Module 9: Using Operations Manager 2007 Command Shell

17

Get-Task used to retrieve the specified Operations Manager monitoring task objects -Path specifies the path to the monitoring objects from which to retrieve tasks. -MonitoringObject when specified, the tasks associated with the specified monitoring object are retrieved. - Id specifies the GUID of the monitioring object task to retrieve. -Task specifies the monitoring task to start -Overrides specifies any task overrides -Credential specifies the credentials under which to run the monitoring task -Asynchronous when specified, the monitoring task runs asynchronously. If this parameter is not specified, the command will wait until the task completes before returning control. -TargetMonitoringObject optionally specifies the monitoring object to run the task against. -Confirm prompts for confirmation before running the task. -Path specifies the path of the management group connections for the desired tasks -Id specifies the GUID of the task result to obtain. -BatchID Specifies the GUID of the batch of the tasks to retrieve the results of.

Start-Task Used to start a specified Operations Manager task

Get-TaskResult used to retrieve the results of a task

When run by itself, Get-TaskResult will list all the accumulated task results known on the management server. Over time, this will grow to quite a list, so you will want to try narrowing it down with either a Where-Object cmdlet or the -criteria parameter.

18

Module 9: Using Operations Manager 2007 Command Shell

Action Cmdlets

These cmdlets are designed for managing agent actions in Operations Manager. They are used to list the pending agent actions, and approve or deny a pending agent action. Get-AgentPendingAction used to retrieve pending Operations Manager actions Path which specifies the path to the Management Group from which to retrieve the list of pending agent actions. -AgentPendingAction specifies the pending actions to approve. You can approve multiple actions by separating the AgentPendingAction objects with commas. -Confirm prompts for confirmation before approving the pending actions -AgentPendingAction specifies the pending actions to reject. You can approve multiple actions by separating the AgentPendingAction objects with commas. -Confirm prompts for confirmation before rejecting the pending actions

Approve-AgentPendingAction used to approve a pending agent action

Reject-AgentPendingAction used to reject a pending agent action

Module 9: Using Operations Manager 2007 Command Shell

19

Notification Cmdlets

These cmdlets are designed for managing notification operations in Operations Manager. These cmdlets are used for listing the current subscription settings, and enabling and disabling rules. Get-NotificationSubscription used to retrieve notification subscriptions associated with a particular notification subscription ID -Path specifies the path of the management groups from which to retrieve the notification subscriptions. -Id specifies the GUID of the notification subscription to retrieve. -NotificationSubscription specifies the subscription to enable -Confirm prompts for confirmation before disabled the subscription. -NotificationSubscription specifies the subscription to disable -Confirm prompts for confirmation before disabled the subscription.

Enable-NotificationSubscription used to enable a notification subscription.

Disable-NotificationSubscription used to disable a notification subscription.

Get-NotificationAction used to retrieve notifications actions associated with a specific notification action ID

20

Module 9: Using Operations Manager 2007 Command Shell

-Path specifies the path of the management groups from which to retrieve the notification actions. -Id specifies the GUID of the notification action to retrieve.

Get-NotificationEndpoint used to retrieve notifications end points associated with a specific notification end point ID -Path specifies the path of the management groups from which to retrieve the notification end points. -Id specifies the GUID of the notification end point to retrieve.

Get-NotificationRecipient used to retrieve notifications recipients associated with a specific notification recipient ID -Path specifies the path of the management groups from which to retrieve the notification recipients. -Id specifies the GUID of the notification recipient to retrieve.

Alert Cmdlets

With Alert objects, you can view and manage pending alerts on your Operations Manager server. You can also wade through the alert history as recorded in the Operations Manager database.

Module 9: Using Operations Manager 2007 Command Shell

21

Get-Alert used to retrieves Operations Manager alert(s). -Criteria used to specify a specific set of alerts to retrieve -Recurse by default, only alerts for the current monitoring object are retrieved. When the -Recurse parameter is used, alerts for the child objects of the current monitoring object are also retrieved. -Id retrieves the alert with the specifid GUID. -MonitoringObject retrieves alerts for the specified monitoring object.

The information contained in an alert object can be very extensive, so take advantage of the Format-List cmdlet (aliased as fl) to make the output more readable (especially if you decide to check out the Description property).

Resolve-Alert used to resolve a set of active Operations Manager alerts. -Alert specifies the alert to resolve. -Comment an optional comment to be included with the history of the alert object. -Confirm causes a prompt to confirm resolution of the alert. This is a good parameter to take advantage of when sifting through a set of alerts.

Get-AlertDestination used to retrieve the destination connection for a specified set of Operations Manager alerts -Alert used to specify the alert to retrieve the destination connector for Set-AlertDestination used to set the destination connector for a specified set of Operations Manager alerts. -Alert specifies the alert to modify the destination connector for. -Connector specifies the Operations Manager connector to set as the new alert destination -Comment an optional comment about the new alert destination setting. -Confirm causes a prompt to verify the change in destination connector.

Get-AlertHistory used to retrieve the history for a set of specified Operations Manager alerts -Alert, which specifies the alert to retrieve the history of.

22

Module 9: Using Operations Manager 2007 Command Shell

Management Server Cmdlets

These cmdlets are used to manage connections to Operations Manager Management Servers and administer the default settings. The default management server is used as the connection point unless another management server is manually connected Get-ManagementServer used to retrieve the specified Management Server from the current Management Group -Root when specified, the cmdlet retrieves only the root Management Server of the group

Get-DefaultSetting used to retrieve the default configuration settings for the current Management Server. -Path - specifies the path to the management groups from which to retrieve default settings

Set-DefaultSetting used to set one or more of the default configuration settings for a Operations Manager Management Server -Name the name of the default server setting you want to modify. This parameter is case-sensitive. -Value the new value for the default server setting.

Module 9: Using Operations Manager 2007 Command Shell

23

-Path specifies the path to the management groups to the new defaults settings should be applied. -Confirm prompts for confirmation before applying the new default settings to the management groups. -Path specifies the path to the Management Groups to retrieve connectors for. -MonitoringAlert specifies the alert for which to retrieve connectors -Id specifies the GUID of the connector to retrieve.

Get-Connector used to retrieve the connectors for a Management Group

Get-ManagementGroupConnection used to find all open connections to Operations Manager Management groups. This cmdlet does not take any parameters. New-ManagementGroupConnection used to create and open a new connection to a server in a Management Group -ConnectionString specifes the connection string to the desired Management Group -Credential specifies the Credential object to use when connecting to the new Management Group

Remove-ManagementGroupConnection used to remove a connection to an Operations Manager Management Group -Path specifies the path to the management groups from which to remove the connection. -Connection specifies the management connection to remove -Confirm prompts for confirmation before remove the management group connection.

24

Module 9: Using Operations Manager 2007 Command Shell

Maintenance Window Cmdlets

These cmdlets are used to create, modify and retrieve information about monitoring object maintenance windows. Maintenance windows are used to suspend monitoring of a system while work is being performed on the system. Get-MaintenanceWindow used to retrieve the maintenance window information for a specified Operations Manager monitoring object. The monitoring object must be in maintenance mode. -History specifies that the history of the maintenance window should be retrieved. -Path specifies the path to the monitoring objects on which to retrieve the maintenance window. -MonitoringObject specifies the monitoring object to retrieve the maintenance window

New-MaintenanceWindow used to create a new Operations Manager maintenance window for a monitoring object -StartTime specifies the beginning time of the maintenance window. This parameter will accept either a string value or a DateTime object.

Module 9: Using Operations Manager 2007 Command Shell

25

-EndTime specifies the ending time of the maintenance window. This parameter will accept either a string value or a DateTime object. -Path specifies the path to the monitoring objects on which to set the maintenance window. -MonitoringObject specifies the monitoring object that will be placed in maintenance mode for the duration of the window -Reason optionally assigns a reason to the maintenance window. -Comment an optional comment about the maintenance window. -Confirm causes the cmdlet to prompt the user to confirm the creation of the new maintenance window.

Set-MaintenanceWindow used to update the properties of a specified maintenance window. The monitoring object must be in maintenance mode -Path specifies the path to the monitoring objects on which to set the maintenance window. -MonitoringObject specifies the monitoring object on which to set the maintenance window. -Endtime specifies the time the maintenance window will end. The value can be either a string format or a DateTime object. -Reason this parameter specifies the reason for the maintenance window. -Comment an optional comment about the maintenance window.

When creating or modifying a maintenance window, a reason can be assigned to the window. The list of reason codes accepted by the New-MaintenanceWindow and Set-MaintenanceWindow cmdlets include: ApplicationInstallation ApplicationUnresponsive ApplicationUnstable LossOfNetworkConnectivity PlannedApplicationMaintenance UnplannedApplicationMaintenance PlannedHardwareInstallation UnplannedHardwareInstallation PlannedHardwareMaintenence

26

Module 9: Using Operations Manager 2007 Command Shell

UnplannedHardwareMaintenence PlannedOperatingSystemReconfiguration UnplannedOperatingSystemReconfiguration PlannedOther UnplannedOther SecurityIssue

Monitoring Cmdlets

These cmdlets are used to work with monitoring objects in Operations Manager. They can be used to retrieve monitoring objects, search the monitoring classes for specific monitoring objects, and retrieve overrides assigned to the monitoring objects. Get-MonitoringObject used to retrieve a set of specified Operations Manager monitoring objects. -Path specifies the path to the monitoring objects to retrieve. -Id specifes the GUID of the monitoring object to retrieve.

Module 9: Using Operations Manager 2007 Command Shell

27

-MonitoringClass specifies that only monitoring objects of a specified monitoring class should be returned -Criteria used to narrow down the returned set of monitoring objects.

Get-MonitoringObjectPath used to retrieve the path to a specified Operations Manager monitoring object. -MonitoringObject specifies the monitoring object to retrieve the management path for -Id specifes the GUID of the monitoring object to retrieve. -DriveQualified specifies that a drive-qualified path should be returned for the monitoring object. -Path specifies the path to the monitoring objects to retrieve.

Get-MonitoringObjectProperty used to retrieve the properties of a specified Operations Manager monitoring object MonitoringObject specifies the monitoring object to retrieve the properties of Get-MonitoringClass used to retrieve a set of specified Operations Manager monitoring classes. -Path specifies the path (or paths, separated by commas) to the monitoring objects from which to retrieve monitoring classes. -Id specifies the GUID of the monitoring class to retrieve. -Name specifies the name of the monitoring class to retrieve. -MonitoringObject specifies a particular monitoring object to return the monitoring class. -ManagementPack specifies a management pack from which to return a list of monitoring classes.

Get-Override used to retrieve the overrides provided by either an Operations Manager Management Pack or a monitoring task. -ManagementPack specifies which Management Pack from which to list available overrides -Task specifies the monitoring task from which to list available overrides -Criteria used to narrow the result set of overrides -Path specifies the path (or paths, separated by commas) to the monitoring objects from which to retrieve overrides

28

Module 9: Using Operations Manager 2007 Command Shell

Performance Counter Cmdlets

Performance counter cmdlets are used to retrieve performance data on Operations Manager clients. Get-PerformanceCounter used to retrieve the Operations Manager performance data items on the selected management server. -Path path to the monitoring object -Id GUID of the performance counter -Criteria set of performance counter objects to retrieve

Get-PerformanceCounterValue used to retrieve values for performance counter within a specified time frame -PerformanceCounter which performance counter to view data from -StartTime the beginning date and time for monitoring -EndTime the ending date and time for monitoring

Module 9: Using Operations Manager 2007 Command Shell

29

Miscellaneous Cmdlets

These are cmdlets that do not fit a specific category, but will be used often with other Operations Manager cmdlets. Get-Credential used to create a PowerShell Credential (PSCredential) object, This type of object is used when a cmdlet needs a set of user credentials in order to execute Credential parameter used to specify a username to be used in the PSCredential object. If this parameter is omitted, a dialog box will be displayed to retrieve a username and password. -Path specifies the path to monitoring objects from which events should be retrieved. -MonitoringObject specifies the monitoring object from which events should be retrieved. -Criteria Specifies the criteria that events must match to be returned. -Recurse Determines whether to retrieve events for only the specified monitoring object(s) or include child monitoring object events.

Get-Event used to retrieve Operations Manager events

30

Module 9: Using Operations Manager 2007 Command Shell

-Id specifies the GUID of the event to retrieve. -Path specifies the path to the Management Groups from which to retrieve user roles. -Id specifies the GUID of the user role to retrieve.

Get-UserRole used to retrieve the specified Operations Manager user role objects

Module 9: Using Operations Manager 2007 Command Shell

31

Lab: Using the Command Shell

In this lab you will contrast entering commands directly within the command shell with creating a script that will perform the same function. Both exercises will add a user to the Read Only Operators user role. The script will be written to prompt for the user name, add the user to the user role and then ask if you want to add another user. After completing this lab, you will be able to: Enter the commands to execute an administrative task Create a script to execute an administrative task

Estimated time to complete this lab: 20 minutes

Lab Setup
For this lab, you will use the available virtual machine environment. Before you begin the lab, you must: Verify that the DC1, OpsMgrSQL, CHI-RMS virtual machines are running If the virtual machines are not running: Start the DC1 virtual machine After DC1 is running, start the OpsMgrSQL virtual machines

32

Module 9: Using Operations Manager 2007 Command Shell

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

Lab Scenario
User accounts need to be added to user roles within the management group. Instead of using the Operations Console, you are to validate whether the Command Shell is a viable administrative tool when managing the management group.

Exercise 1: Running Individual Commands


In this exercise, you will enter the commands that will add a user to the Read Only Operators user role. The principal tasks for this exercise are as follows: Enter the commands that will add a user to the Read Only Operators user role. Verify the user has been added to the user role.
Supporting information 2..Add a user to the Read Only Operators role. 2..Verify user role membership. Enter the command Get-UserRole | where {$_.Users match KEwart} and press Enter Verify that the Read Only Operators group appears Enter the following commands and press Enter after each line $userRole = Get-UserRole | where {$_.Name eq OperationsManagerReadOnlyOperators} $userRole.Users.Add(KEwart) $userRole.Update() Log on to CHI-RMS as SOmelc Select Start > All Programs > System Center Operations Manager 2007 > Command Shell

Tasks 1..Log on and start the Command Shell,

Exercise X: Scripting Commands


In this exercise, you will create a script that will prompt for a user name to be added to the Read Only Operators user role. The principal tasks for this exercise are: Set the execution policy to allow local scripts to execute

Module 9: Using Operations Manager 2007 Command Shell

33

Create a script that will add users to the Read Only Operators user role Verify the addition of the user to the user role
Supporting information To enable your scripts to run, enter the command setexecutionpolicy remotesigned and press enter

Tasks 2..Set the execution policy.

1..Create the script

Open Notepad Enter the following commands in Notepad Write-Host Add Account to User Role $userRole = Get-UserRole | where {$_.Name eq OperationsManagerReadOnlyOperators} Do { $UserToAdd = Read-Host Enter user name: $UserRole.Users.Add($UserToAdd) $UserRole.Update() } While ((Read-Host Add Another User (Y/N)?) eq Y)

2..Run the script. 2..Verify the outcome.

.Save the file as c:\Labs\AddUserToReadOnlyOps.ps1

Open Command Shell Enter c:\labs\AddUserToReadOnlyOps.ps1 When prompted for a user name, enter DAlexa and press enter When prompted for another user, enter N and press enter

Enter Get-UserRole | where {$_.Users match DAlexa} and press Enter Verify that the Read Only Operators group appears Close the command shell

Lab Shutdown
After you complete the lab, you must shut down the virtual machines and save any changes.

You might also like