MathieuBuisson / Powershell-VMware

Powershell or PowerCLI modules for VMware administration/troubleshooting tasks
71 stars 31 forks source link

Strong Typing Disallows Certain Datastore Types #1

Closed Vulp-OS closed 9 years ago

Vulp-OS commented 9 years ago

On line 89 of Get-StorageViewsReport.psm1, you give the variable $Datastore a type of [VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl[]]

For vmWare configurations where the type NasDatastoreImpl is also used, your code fails. If you don't explicitly declare the type of this variable, the code works for both types.

MathieuBuisson commented 9 years ago

Thank you for highlighting this problem.

I removed the type for the variable $Datastore. Instead, I use [ValidateScript()] validation for the parameter Datastore and check for the type being VmfsDatastoreImpl or NasDatastoreImpl.

You can double-check, but I'm pretty confident this fixes the problem.