Get-Compliance

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.

Syntax

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

Parameters

Required Parameter Name Type Position Features Description
required
Entity
InventoryItem named
  • pipeline
  • Specifies a Template, VirtualMachine, VMHost, Cluster, Datacenter, Folder, or VApp object for which you want to retrieve the compliance status.
    optional
    Baseline
    Baseline[] named
  • pipeline
  • Specifies the baseline for which you want to retrieve the compliance status.
    optional
    ComplianceStatus
    ComplianceStatus named Specifies the status of the compliance you want to retrieve. The valid values are Compliant, NotCompliant, Unknown, and Incompatible.
    optional
    Detailed
    SwitchParameter named Specifies 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.
    optional
    Server
    VIServer[] named
  • pipeline
  • Specifies 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.

    Output

    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.

    Related Commands

    Feedback

    Was this page helpful?