Reader small image

You're reading from  Learning PowerCLI - Second Edition

Product typeBook
Published inFeb 2017
Publisher
ISBN-139781786468017
Edition2nd Edition
Right arrow
Author (1)
Robert van den Nieuwendijk
Robert van den Nieuwendijk
author image
Robert van den Nieuwendijk

Robert van den Nieuwendijk is an IT veteran from the Netherlands with over thirty years of experience in Information Technology. He holds a bachelor degree in software engineering. After working a few years as a programmer of air traffic control and vessel traffic management systems, he started his own company Van den Nieuwendijk Informatica in 1988. Since then he has worked as a freelance systems administrator of OpenVMS, Windows Server, Linux, and VMware vSphere systems, for Dutch governmental organizations and cloud providers. During winter he is also a ski and snowboard instructor at an indoor ski school. With his background as a programmer, he always tries to make his job easier by writing programs or scripts to perform repeating tasks. In the past, he used the C programming language, OpenVMS DCL, Visual Basic Script and KiXtart to do this. Now, he uses Microsoft PowerShell and VMware PowerCLI for all of his scripting work. Robert is a frequent contributor and moderator at the VMware VMTN Communities. Since 2012 VMware awarded him the vExpert title for his significant contributions to the community and a willingness to share his expertise with others. He has a blog at http://rvdnieuwendijk.com where he writes mainly about VMware PowerCLI, Microsoft PowerShell, and VMware vSphere. If you want to get in touch with Robert, then you can find him on Twitter. His username is @rvdnieuwendijk. Robert is also the author of Learning PowerCLI, Packt Publishing.
Read more about Robert van den Nieuwendijk

Right arrow

Chapter 13.  Using vRealize Operations Manager

vRealize Operations Manager (vROPs) is VMware's product for performance monitoring, capacity planning, and alerting. In vROPs, you can install management packs to connect vRealize Operations Manager with products such as vCloud Director, Log Insight, NSX, storage devices, Cisco UCS Manager, and Amazon Web Services. These management packs make it a powerful tool to manage your entire environment. In this chapter, we will discuss the available PowerCLI cmdlets for working with vRealize Operations Manager. Because the cmdlets only scratch the surface of what you can do with vROPs, we will also give some examples of using the API to perform other tasks.

This chapter covers the following topics:

  • Connecting to vRealize Operations Manager servers

  • Retrieving vRealize Operations Manager resource objects

  • Using alerts

  • Retrieving recommendations

  • Retrieving statistic keys

  • Retrieving statistical data

  • Retrieving local user accounts

  • Using the vRealize Operations Manager...

Connecting to vRealize Operations Manager servers


Analog to the Connect-VIServer cmdlet that creates a connection to a vCenter or ESXi server, the Connect-OMServer cmdlet establishes a connection to the specified vRealize Operations Manager server. The syntax of the Connect-OMServer cmdlet is as follows, and the first parameter set is the default:

Connect-OMServer [-Server] <String[]> [-User <String>] [-Password 
    <SecureString>] [-AuthSource <String>] [-Port <Int32>] [-NotDefault]
    [-Force] [-SaveCredentials] [<CommonParameters>]

The -Server parameter is required. The second parameter set is required to connect an Operations Manager Server using a session secret of an existing vRealize Operations Manager session you want to re-establish:

Connect-OMServer [-Server] <String[]> [-Port <Int32>] 
    [-NotDefault] [-Force] -SessionSecret <String> [<CommonParameters>]

The -Server and -SessionSecret parameters are required. The...

Retrieving vRealize Operations Manager resource objects


Resource objects are data centers, folders, clusters, ESXi hosts, datastores, virtual machines, resource pools, and so on. The Get-OMResource cmdlet retrieves vRealize Operations Manager resource objects. The syntax of Get-OMResource cmdlet is as follows. The first parameter set is the default:

Get-OMResource [[-Name] <String[]>] [-ResourceKind <String[]>]
    [-AdapterKind <String[]>] [-Orphaned] [-Server <OMServer[]>] 
    [<CommonParameters>]

The second parameter set is there to retrieve vROPs resource objects by ID:

Get-OMResource -Id <String[]> [-Server <OMServer[]>]
    [<CommonParameters>]

The -Id parameter is required.

The third parameter set is required to retrieve vROPs resource objects by specifying objects from vSphere:

Get-OMResource [-Entity] <VIObjectCore[]> [<CommonParameters>]

The -Entity parameter is required.

If you use the Get-OMResource cmdlet without parameters...

Using alerts


Alerts are alarms that warn you about situations that need attention. The Get-OMAlert cmdlet retrieves alerts from the specified vRealize Operations Manager server. The syntax of the Get-OMAlert cmdlet is given here. The first parameter set is the default:

Get-OMAlert [-Status <OMAlertStatus[]>] [-Impact <OMImpact[]>]
    [-Criticality <OMCriticality[]>] [-Resource <OMResource[]>]
    [-Subtype <OMAlertSubtype[]>] [-AssignedUser <OMUser[]>]
    [-Type <OMAlertType[]>] [-ControlState <OMAlertControlState[]>]
    [-AlertDefinition <OMAlertDefinition[]>] [[-Name] <String[]>]
    [-Server <OMServer[]>] [<CommonParameters>]

The second parameter set is required to retrieve alerts by ID:

Get-OMAlert -Id <String[]> [-Server <OMServer[]>] [<CommonParameters>]

The -Id parameter is required.

If you use the Get-OMalert cmdlet without parameters, it will retrieve all of the available alerts as shown...

Retrieving recommendations


The Get-OMRecommendation cmdlet retrieves recommendations from the specified vRealize Operations Manager server. The syntax of the Get-OMRecommendation cmdlet is as follows:

The first parameter set is required to retrieve recommendations by ID:

Get-OMRecommendation [-Id <String[]>] [-Server <OMServer[]>] 
    [<CommonParameters>]

The second parameter set is required to retrieve recommendations by alert:

Get-OMRecommendation -Alert <OMAlert[]> [-Server <OMServer[]>] 
    [<CommonParameters>]

The third parameter set is required to retrieve recommendations by alert definition:

Get-OMRecommendation -AlertDefinition <OMAlertDefinition[]>
    [-Server <OMServer[]>] [<CommonParameters>]

The Get-OMRecommendation cmdlet has no required parameters.

If you use the Get-OMRecommendation cmdlet without parameters, it retrieves all of the recommendation definitions. The following example retrieves the recommendations, selects...

Retrieving statistic keys


A statistic key identifies a vRealize Operations Manager metric. The Get-OMStatKey cmdlet retrieves vRealize Operations Manager statistic keys. The syntax of the Get-OMStatKey cmdlet is given here. The first parameter set is the default:

Get-OMStatKey [[-Name] <String[]>] [-ResourceKind 
    <String[]>] [-AdapterKind <String[]>] [-Server <OMServer[]>] 
    [<CommonParameters>]

The second parameter set is required to retrieve statistic keys by resource:

Get-OMStatKey [[-Name] <String[]>] -Resource 
    <OMResource[]> [-Server <OMServer[]>] [<CommonParameters>]

The -Resource parameter is required.

The Get-OMStatKey cmdlet without parameters returns all of the statistic keys. There are too many statistic keys to shows in this book. Piping the output of the Get-OMStatKey cmdlet to the Measure-Object cmdlet and displaying the Count property shows us the number of statistic keys, as in the following command:

PowerCLI...

Retrieving statistical data


The Get-OMStat cmdlet retrieves statistical data from the specified vRealize Operations Manager server. The syntax of the Get-OMStat cmdlet is as follows:

Get-OMStat [-Resource] <OMResource[]> [-Key <OMStatKey[]>]
    [-From <DateTime>] [-To <DateTime>] [-IntervalType 
    <OMStatIntervalType>] [-IntervalCount <Int32>] [-RollupType 
    <OMStatRollupType>] [-Server <OMServer[]>] [<CommonParameters>]

The -Resource parameter is required.

In the first example, we will retrieve all of the statistical data for virtual machine DC001 and display the first five objects found, using the following command:

PowerCLI C:\> Get-OMStat -Resource DC001 | Select-Object -First 5

The output of the preceding command is as follows:

Resource Key                               Value Time
-------- ---                               ----- ----
DC001    System Attributes|alert_count_... 0     2/2/2017 9:00:44 PM
DC001    System Attributes...

Retrieving local user accounts


In vRealize Operations Manager, you can authenticate users using local accounts, SSO SAML, Open LDAP, Active Directory, and vCenter Server accounts. The Get-OMUser cmdlet retrieves local user accounts from the specified vRealize Operations Manager server. The syntax of the Get-OMUser cmdlet is given here. The first parameter set is the default:

Get-OMUser [-Enabled <Boolean>] [[-Name] <String[]>]
    [-Email <String[]>] [-Server <OMServer[]>] [<CommonParameters>]

The second parameter set is required to retrieve local users by ID:

Get-OMUser -Id <String[]> [-Server <OMServer[]>] [<CommonParameters>]

The -Id parameter is required.

Using the Get-OMUser cmdlet without parameters will return all of the local user accounts, as follows:

PowerCLI C:\> Get-OMUser

The output of the preceding command is as follows:

Name             FirstName LastName Enabled
----             --------- -------- -------
maintenanceAdmin...

Using the vRealize Operations Manager API


Until now, you have seen the cmdlets available in PowerCLI for vRealize Operations Manager. These cmdlets only explore a small set of things you can do with vRealize Operations Manager. vRealize Operations Manager has a REpresentational State Transfer Application Programming Interface (REST API) that you can easily use from PowerCLI. The $global:DefaultOMServers variable has an ExtensionData property that opens the gate to the API for you. First, we will create a variable $omApi that contains the connection to the vRealize Operations Manager API, using the following command:

PowerCLI C:\> $omApi = $global:DefaultOMServers[0].ExtensionData

The $global:DefaultOMServers variable can be an array containing connections to multiple vRealize Operations Manager Servers. This is why we used [0] to select the first vROPs server.

By piping the output of the $omApi variable to the Get-Member cmdlet, you will see the available properties and methods, as follows...

Disconnecting from vRealize Operations Manager servers


The Disconnect-OMServer cmdlet closes the connection to one or more vRealize Operations Manager servers. The syntax of the Disconnect-OMServer cmdlet is as follows:

Disconnect-OMServer [[-Server] <OMServer[]>] [-Force]
    [-WhatIf] [-Confirm] [<CommonParameters>]

The Disconnect-OMServer cmdlet has no required parameters.

In the following example, we will disconnect from vRealize Operations Manager 192.168.0.62, as follows:

PowerCLI C:\> Disconnect-OMServer -Server 192.168.0.62 -Confirm:$false

The preceding command does not return any output.

Summary


vRealize Operations Manager is VMware's product for performance monitoring, capacity planning, and alerting. PowerCLI contains a limited set of cmdlets to work with vRealize Operations Manager. You have learned to use the cmdlets to connect to and disconnect from vRealize Operations Manager servers, use alerts, retrieve recommendations, retrieve statistical data, and retrieve local user accounts.

Using the vRealize Operations Manager API, you can use all of the capabilities of vROPs. Many examples of using the API were given to retrieve user roles, create and remove users, retrieve solutions and traversalSpecs, and create and retrieve reports.

In the following chapter, Using REST API to manage NSX and vRealize Automation, we will show you how to use VMware NSX and vRealize Automation Center with PowerCLI using REST APIs.

lock icon
The rest of the chapter is locked

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
You have been reading a chapter from
Learning PowerCLI - Second Edition
Published in: Feb 2017Publisher: ISBN-13: 9781786468017
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 £13.99/month. Cancel anytime

Author (1)

author image
Robert van den Nieuwendijk

Robert van den Nieuwendijk is an IT veteran from the Netherlands with over thirty years of experience in Information Technology. He holds a bachelor degree in software engineering. After working a few years as a programmer of air traffic control and vessel traffic management systems, he started his own company Van den Nieuwendijk Informatica in 1988. Since then he has worked as a freelance systems administrator of OpenVMS, Windows Server, Linux, and VMware vSphere systems, for Dutch governmental organizations and cloud providers. During winter he is also a ski and snowboard instructor at an indoor ski school. With his background as a programmer, he always tries to make his job easier by writing programs or scripts to perform repeating tasks. In the past, he used the C programming language, OpenVMS DCL, Visual Basic Script and KiXtart to do this. Now, he uses Microsoft PowerShell and VMware PowerCLI for all of his scripting work. Robert is a frequent contributor and moderator at the VMware VMTN Communities. Since 2012 VMware awarded him the vExpert title for his significant contributions to the community and a willingness to share his expertise with others. He has a blog at&nbsp;http://rvdnieuwendijk.com where he writes mainly about VMware PowerCLI, Microsoft PowerShell, and VMware vSphere. If you want to get in touch with Robert, then you can find him on Twitter. His username is @rvdnieuwendijk. Robert is also the author of Learning PowerCLI, Packt Publishing.
Read more about Robert van den Nieuwendijk