Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 230200

Re: Export Compliance Reports

$
0
0

To make sure the reading of the hostnames works correctly, can you check if the following actually produces 2 objects ?

Get-VMHost -Name (Get-Content "C:\esxihosts.txt")

Since the Get-Compliance cmdlet accepts multiple objects on the Entity parameter, and since the values can come from the pipeline, you could drop the ForEach altogether.

Something like this

# Get today's date

$CurrentDate = Get-Date

$CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hhmmss')

# Set Output Path

$path = "C:\Reports\"

 

Get-VMHost -Name (Get-Content "C:\esxihosts.txt") |

Get-Compliance -Detailed |

Select @{N="Host Name";E={$_.Entity.Name}},

    @{N="Baseline";E={$_.Baseline.Name}},

    @{N="Compliant Patches";E={$_.CompliantPatches | Measure-Object | Select -ExpandProperty Count}},

    @{N="Not Compliant Patches";E={$_.NotCompliantPatches | Measure-Object | Select -ExpandProperty Count}},

    @{N="Unknown Patches";E={$_.UnknownPatches | Measure-Object | Select -ExpandProperty Count}},

    @{N="Not Applicable Patches";E={$_.NotApplicablePatches | Measure-Object | Select -ExpandProperty Count}},

    Status |

Export-Csv "$path\PatchComplianceReport_$CurrentDate.csv" -UseCulture -NoTypeInformation


Viewing all articles
Browse latest Browse all 230200

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>