alanrenouf / vCheck-vSphere

vCheck Daily Report for vSphere
MIT License
735 stars 326 forks source link

Latest PowerCLI has broken functions adding LastPoweredOn/Off properties to VM #526

Closed Scepticalist closed 7 years ago

Scepticalist commented 7 years ago

Edit the plugin "00 Connection Plugin for vCenter" as follows:

In the two function definitions Get-VMLastPoweredOffDate and Get-VMLastPoweredOnDate:

Replace

VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl

With

VMware.VimAutomation.ViCore.Impl.V1.VM.UniversalVirtualMachineImpl

gregharms commented 7 years ago

https://blogs.vmware.com/PowerCLI/2016/04/powercli-best-practice-correct-use-strong-typing.html

Instead of updating the type to another implementation type, we should follow the recommendation in the above link to be resilient to future PowerCLI changes. [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine]

gregharms commented 7 years ago

Submitted my first ever pull request for this. Hope I followed the contribution guidelines OK.

Scepticalist commented 7 years ago

Excellent- I hadn't seen that article on types. I'll edit my implementation - thanks for the submission

Sneddo commented 7 years ago

Awesome, I hadn't seen that article as well. Thanks for your contribution, I've merged the pull just now. In future, you just need to bring your branch up to date before submitting the pull request. That way it's much easier to merge into the repository.