VMware Cloud Community
roluje
Enthusiast
Enthusiast

get-compliance error "module not found"

Whenever I use get-compliance and try to target a group of objects (cluster,datacenter,vm group) with the -entity param, I get a nasty error:

[vSphere PowerCLI] U:\> Get-Compliance -Entity Main
Get-Compliance : 3/9/2011 1:54:13 PM    Get-Compliance        Method not found:
'System.Collections.Generic.List`1<VMware.VimAutomation.ViCore.Interop.V1.Inve
ntory.VirtualMachineInterop> VMware.VimAutomation.ViCore.Interop.V1.Service.Inv
entoryService.GetVM(System.String[], System.String[], System.String[], System.C
ollections.Generic.List`1<VMware.VimAutomation.ViCore.Interop.V1.Inventory.VICo
ntainerInterop>, Boolean, VMware.VimAutomation.ViCore.Interop.V1.DatastoreManag
ement.DatastoreInterop[])'.
At line:1 char:15
+ Get-Compliance <<<<  -Entity Main
    + CategoryInfo          : NotSpecified: (:) [Get-Compliance], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VumAutomatio
   n.Commands.GetCompliance

I am a systems engineer and administrator and not a developer so take it easy on me Smiley Happy..  my entity known as "Main" is a datacenter.  I get the same message when targeting clusters, or groups.  I can target individual hosts and vms without any issue.

my environment:  client is Windows 7 Enterprise, vCenter 4.1, hosts are 4.0, 4.1 and 4.1u1 all are full ESX (in process of upgrading).  I have the vsphere powercli 4.1.1 and updatemanager powercli 4.1 (both are the newest version available that I can find). 

Anyone else seeing this behavior? Anyone have an idea how I can target a group of objects?  I try Get-VMHost -location main |Get-Compliance and it works fine but get-cluster -name mainclust01 |Get-Compliance doesn't nor does Get-Datacenter -name main |Get-Compliance.  Help.

Tags (2)
Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership

I'm afraid the Get-Compliance cmdlet doesn't accept an array of objects for the -Entity parameter.

And there seems to be indeed a problem when you pass anything else but a VirtualMachineImpl or a VMHostImpl object to the -Entity parameter, although the help says you could also pass a Cluster, Datacenter, Folder or VApp.

As a bypass you can do

Get-Datecenter -Name MyDC | Get-VMHost | %{Get-Compliance -Entity $_}

or

Get-CLuster -Name MyCluster | Get-VMHost | %{ Get-COmpliance -Entity $_}

or

Get-VMHost -Location (Get-Folder -Name MyFolder) | %{Get-COmpliance -Entity $_}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

roluje
Enthusiast
Enthusiast

Thanks for your input LucD.  Sorry for the delay but I was away from the office for a bit.  Anyway, I was looking for compliance of VMs for tools version and hardware version.  I iterated through all the VMs (about 260 right now) to get what I was needing.  I just wanted to report the error I found and I'm glad (sort of) to know that I am not the only one Smiley Happy.

I used something like:

get-vm -location mainclust01 | Get-Compliance

where mainclust01 is the name of the cluster I was interested.  Of course I could use a datacenter name or folder name as the value to location parameter.

I called support to report this issue and they were not helpful at all!  After explaining that I was using the UpdateManager PowerCli cmdlets, the rep on the phone put me in queue and I waited 50 some minutes (not typical) to find out that they put me in the "install and OS" queue and they had no clue about the powercli and they could only point me to the forums.  Anyway, hopefully someone see's this so either the help can be updated and corrected or that the cmdlet can be updated to work as described in the help.

As with most things, there are multiple ways to get what you need.  It would be real nice to have get-compliance work properly on Datacenters, clusters, folders, etc as described.  I look forward to it getting updated... please Smiley Happy.

Reply
0 Kudos
nmladenov
Contributor
Contributor

Hi roluje,

Actually the issue you hit, is known. It is bug in PowerCLI core, not in VUM PowerCLI and will be fixed in upcoming release. If you use VUM PowerCLI 4.1 with PowerCLI 4.1 (not 4.1.1), you won't get this error.

Regards,

Nikolay

Nikolay Mladenov, Quality Engineer, VMware
Reply
0 Kudos
aravinds3107
Virtuoso
Virtuoso

Hi Luc,

I was trying to get the compliant status of all cluster in my vCenter server and have included the -Detailed parameter from your get-cluster one liner, When i run the command it shows teh report fine but when i try to export to export-CSV it doesnt export it correct format,

Could you please let me know if i am missing any parameter.

Get-Cluster -Name $Cluster | Get-VMHost|%{Get-Compliance -Detailed -Entity $_} | Export-Csv E:\ESXPatch\CompliancyReport.csv -NoTypeInformation

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful |Blog: http://aravindsivaraman.com/ | Twitter : ss_aravind
Reply
0 Kudos
LucD
Leadership
Leadership

The -Detailed parameter produces a more complex object.

On screen this formats correctly, because the format file VMware.VumAutomation.Format.ps1xml contains the instructions to format the PatchBaselineCompliance object.

Unfortunately, the Export-Csv cmdlet doesn't  know how to format the PatchBaselineCompliance object.

The only solution is to use a Select statement where you specify the properties you want in the CSV file.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
aravinds3107
Virtuoso
Virtuoso

Hi Luc,

i have select-object and selected the property which i need on CSV, it gives header correctly but the contect is still the same. Only the Entity and Status is getting exported correctly.. for the rest i get the ourput as VMware.VumAutomation.Types.Patch[]

If you find this or any other answer useful please consider awarding points by marking the answer correct or helpful |Blog: http://aravindsivaraman.com/ | Twitter : ss_aravind
Reply
0 Kudos
LucD
Leadership
Leadership

That's because the property you try to export is an array (indicated by the square brackets after the typename).

There are 2 options:

  1. You introduce a foreach loop where you run through all the elements of the array
  2. You use the .Net function Join to convert the array to a (long) string. Like this for example

Get-VMHost | Get-Compliance -Detailed | `
Select @{N="Host";E={$_.Entity.Name}},     @{N="Baseline";E={$_.Baseline.Name}},     @{N="CompliantPatches";E={[string]::Join(',',($_.CompliantPatches | %{$_.Name}))}} | `
Export-Csv "C:\compliance-report.csv" -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos