PowerCLI Reference

Get-Compliance

Synopsis

This cmdlet retrieves baseline compliance data for the specified object.

Syntax

Get-Compliance [-Server <VIServer[]>] [-Entity] <InventoryItem> [-ComplianceStatus <ComplianceStatus>] [-Baseline <Baseline[]>] [-Detailed] [<CommonParameters>]

Related Commands

Online version
Test-Compliance

Detailed Description

This cmdlet retrieves baseline compliance data for the specified object of type Template, VirtualMachine, VMHost, Cluster, Datacenter, Folder, and VApp. The cmdlet returns information about the compliance of the specified entity with the baselines that are attached to it. If the entity is a container, the cmdlet returns compliance data for all objects in the container.

Parameters

NameDescriptionRequired?Pipeline InputDefault Value
ServerSpecifies the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers.falsetrue (ByValue)
EntitySpecifies a Template, VirtualMachine, VMHost, Cluster, Datacenter, Folder, or VApp object for which you want to retrieve the compliance status.truetrue (ByValue)
ComplianceStatusSpecifies the status of the compliance you want to retrieve. The valid values are Compliant, NotCompliant, Unknown, and Incompatible.falsefalse
BaselineSpecifies the baseline for which you want to retrieve the compliance status.falsetrue (ByValue)
DetailedSpecifies that you want to retrieve detailed information about the compliance. For patch baselines, the patches with different statuses are listed. For VMTools upgrade baselines, the detailed information contains the VMware Tools status. For VM Hardware upgrade baseline, the recommended VM Hardware version and the current VM Hardware version are displayed.falsefalse

Return Type

VMware.VumAutomation.Types.BaselineCompliance

Notes

Examples

-------------- Example 1 --------------

Get-Compliance -Entity VM

Retrieves a list of all baselines attached to the VM virtual machine and shows their compliance status and the number of the Compliant, NotCompliant, Unknown and NotApplicable patches.

-------------- Example 2 --------------

Get-Compliance -Entity $datacenter

Retrieves a list of all baselines attached to the datacenters in $datacenter and shows their compliance status and the number of the Compliant, NotCompliant and Unknown patches.

-------------- Example 3 --------------

Get-VM -Name VM | Get-Compliance

Retrieves a list of all baselines attached to the VM virtual machine and shows their compliance status and the number of the Compliant, NotCompliant, Unknown and NotApplicable patches.

-------------- Example 4 --------------

Get-DataCenter DataCenter | Get-VM "VM*" | Get-Compliance

Retrieves the compliance status for all virtual machines in the Datacenter datacenter whose names start with "VM".

-------------- Example 5 --------------

$statuses = Get-Compliance -Entity VM -ComplianceStatus Unknown

if (([array]($statuses)).Count -gt 0) {Scan-Inventory -Entity VM}

Retrieves the compliance status of the baselines attached to the VM virtual machine. If there is at least one baseline with Unknown compliance status, a scan is started.


Copyright © 1998 - 2015 VMware, Inc. All rights reserved.