VMware Cloud Community
qdljc
Contributor
Contributor
Jump to solution

get-esxcli V2, esxcli.storage.vmfs.unmap, "does not contain a method named 'unmap'"

PSVersion                      6.0.2

VMware.PowerCLI        10.1.0.8403314

>$esxcli = Get-EsxCli -VMHost "host1" -V2

>$ds = Get-VMHost "host1" | Get-Datastore | select -first 1

>$esxcli.storage.vmfs.unmap("4000",$ds,$null)

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.EsxCli.EsxCliElementImpl] does not contain a method named 'unmap'.

At line:1 char:1

+ $esxcli.storage.vmfs.unmap("4000",$ds,$null)

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

+ CategoryInfo          : InvalidOperation: (unmap:String) [], RuntimeException

+ FullyQualifiedErrorId : MethodNotFound

Without -V2, it running no errors. Why?

LucD

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

With the V2 version of Get-Esxcli, you have to use the Invoke method, something like this.

$sArg = @{

   volumelabel = $ds.Name

   reclaimunit = 40000

}

$esxcli.storage.vmfs.unmap.Invoke($sArg)

Note that you can get the parameters in the hash table with the CreateArgs method.

Optional parameters can be left out, no more need to specify $null for those

$esxcli.storage.vmfs.unmap.CreateArgs()

See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for some more info.


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

View solution in original post

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

With the V2 version of Get-Esxcli, you have to use the Invoke method, something like this.

$sArg = @{

   volumelabel = $ds.Name

   reclaimunit = 40000

}

$esxcli.storage.vmfs.unmap.Invoke($sArg)

Note that you can get the parameters in the hash table with the CreateArgs method.

Optional parameters can be left out, no more need to specify $null for those

$esxcli.storage.vmfs.unmap.CreateArgs()

See PowerCLI 6.3 R1: Get-ESXCLI Why the V2? for some more info.


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

Reply
0 Kudos
qdljc
Contributor
Contributor
Jump to solution

THKS,:smileylaugh:

Yes. It works GREAT!

$myarg = $esxcli.storage.vmfs.unmap.CreateArgs()

$myarg

Name                      Value
----                      -----
reclaimunit                Unset, ([long], optional)
volumeuuid                Unset, ([string], optional)
volumelabel               Unset, ([string], optional)

$myarg = @{reclaimunit = 40000 ; volumelabel = $dsName }

$esxcli.storage.vmfs.unmap.invoke($myarg)

Reply
0 Kudos