VMware Cloud Community
SyzygyDE
Contributor
Contributor

Problem Get-Datastore datastore_name etc. - everytime i got an error

hello together,

whatever i want to run:

Get-VMHost Hostname | Get-StorageViewsReport | Format-Table -auto

Get-StorageViewsReport | Format-Table -auto

etc.

i got an error:

Get-StorageViewsReport : Cannot process argument transformation on parameter 'VM'. Cannot convert the "VMNAME" value of type "VMware.VimAutomation.ViCore.Impl.V1.VM.UniversalVirtualMachineImpl" to type "VMware.VimAutomation.ViCore.Impl.V1.Inventory.VirtualMachineImpl".

At line:1 char:20

+ Get-VMHost HOSTNAME | Get-StorageViewsReport | Format-Table -auto

+                    ~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidData: (:) [Get-StorageViewsReport], ParameterBindingArgumentTransformationException

    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-StorageViewsReport

i want to see

a) Snapshots on a specific datastore like before in the Storage Monitoring and Reporting missing Plugin

aa) Snapshots of an an specific VM

b) delete the Snapshots via powerCli

Please help

0 Kudos
9 Replies
LucD
Leadership
Leadership

I assume that you are referring to the Get-StorageViewsReport script from KB2112085 ?

If that is the case, the problem is caused by the type declaration for the VM parameter and the fact that you are using PowerCLI 6.3 (you can check by doing a Get-PowerCLIVersion).

The problem, and it's fix, is described in PowerCLI Best Practice: Correct Use of Strong Typing

In short, replace the parameter declarations with

[cmdletbinding(DefaultParameterSetName="ByDatastore")]

    param(

        [string]$VIServer = "localhost",

       

        [Parameter(ParameterSetName='ByVM')]

        [switch]$ByVM,

        [Parameter(ValueFromPipeline = $True,

        ParameterSetName='ByVM',

        ValueFromPipelineByPropertyName=$True,Position=0)]  

        [VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]]$VM = (Get-VM),

        [Parameter(ParameterSetName='ByDatastore')]

        [switch]$ByDatastore,

        [Parameter(ValueFromPipeline = $True,

        ParameterSetName='ByDatastore',

        ValueFromPipelineByPropertyName=$True,Position=0)]  

        [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.VmfsDatastore[]]$Datastore = (Get-Datastore),

        [Parameter(ParameterSetName='ByHost')]

        [switch]$ByHost,

        [Parameter(ValueFromPipeline = $True,

        ParameterSetName='ByHost',Position=0)]  

        [VMware.VimAutomation.ViCore.Types.V1.Inventory.VMHost[]]$Host = (Get-VMHost)

    )


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

0 Kudos
SyzygyDE
Contributor
Contributor

Now i got the Message

Cannot process argument transformation on parameter 'Datastore'. Cannot convert the "DATASTORENAME" value of type "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.NasDatastoreImpl" to type "VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.VmfsDatastore"

did i forgot something ?

Sorry i am not so familiar with this powercli...

0 Kudos
LucD
Leadership
Leadership

No, but it looks like you are using NFS based datastores.

I don't think that the script was intended for NFS, only VMFS afaik.


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

0 Kudos
SyzygyDE
Contributor
Contributor

yes only NFS Datastores.

any chance to get the same data via powercli or any other tool like before with the Storage Views tab ?

0 Kudos
LucD
Leadership
Leadership

Not sure if the data is available for NFS datatores, and I can't test right now since I don't have any NFS datastores handy.

But you should be able to test that yourself.

In the script change this line

        [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.VmfsDatastore[]]$Datastore = (Get-Datastore),

by this line

        [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.NasDatastore[]]$Datastore = (Get-Datastore),

and give it a try


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

0 Kudos
SyzygyDE
Contributor
Contributor

now i got

Cannot process argument transformation on parameter 'Datastore'. Cannot convert the "Storage1 (1)" value of type "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl" to type "VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.NasDatastore".

Storage1 (1) is the local storage of the ESXi Hosts and not needed / used for VMs etc.

before, i got errors regarding the "real" datastores.

0 Kudos
LucD
Leadership
Leadership

Yes, of course, you get the original error again.

The local disk is not a NFS datastore.

I would like to see the errors for the NFS datastores


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

0 Kudos
SyzygyDE
Contributor
Contributor

hello,

with

"[VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.VmfsDatastore[]]$Datastore = (Get-Datastore),"

i got errors

Cannot process argument transformation on parameter 'Datastore'. Cannot convert the "DATASTORENAME" value of type "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.NasDatastoreImpl" to type "VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.VmfsDatastore"

where DATASTORENAME our NFS Datastore is

then i tried your suggestion:

[quote]

change this line

        [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.VmfsDatastore[]]$Datastore = (Get-Datastore),

by this line

        [VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.NasDatastore[]]$Datastore = (Get-Datastore),

[/quote]

then i got

Cannot process argument transformation on parameter 'Datastore'. Cannot convert the "Storage1 (1)" value of type "VMware.VimAutomation.ViCore.Impl.V1.DatastoreManagement.VmfsDatastoreImpl" to type "VMware.VimAutomation.ViCore.Types.V1.DatastoreManagement.NasDatastore".

where STORAGE1 (1) is one of the local storage of an ESXi Host (and not used for VMs )

regards

0 Kudos
LucD
Leadership
Leadership

The script in it's current form can't handle the types that are used by PowerCLI 6.3.

I gave a quick fix by changing the parameter type to, or VmfsDatastore for VMFS datastore, or NasDatastore for NFS datastores.

With neither of the two quick fixes will the script be able to handle a mix of VMFS and NFS datastores, that would require a more fundamental overhaul of the script.


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

0 Kudos