VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl] does not contain a method named 'op_Addition'.

Hi,

I am getting the below error , please help.

Error

Method invocation failed because [VMware.VimAutomation.ViCore.Impl.V1.Inventory.VMHostImpl] does not contain a method named 'op_Addition'.

At D:\RDM_Attach\New\2_Perennial_Reservation_RDM_CSV.ps1:34 char:2

+  $vmhost + " " + $rdm.Canonical_Name + " " + "IsPerenniallyReserved=  ...

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

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

    + FullyQualifiedErrorId : MethodNotFound

Script

$esxis = get-cluster MyClus | get-vmhost

$in_csvpath = '.\1_Host_LUN_Mapping_Info.csv'

$rdmlist = Import-Csv -Path $in_csvpath

foreach ($vmhost in $esxis){

$myesxcli = Get-EsxCli -VMHost $vmhost

foreach ($rdm in $rdmlist)

{

$diskinfo = $myesxcli.storage.core.device.list($rdm.Canonical_Name) | Select -ExpandProperty IsPerenniallyReserved

$vmhost + " " + $rdm.Canonical_Name + " " + "IsPerenniallyReserved= " + $diskinfo

#$myesxcli.storage.core.device.setconfig($false,$rdm.Canonical_Name,$false)

if($diskinfo -eq "false")

{

write-host "Configuring Perennial Reservation for LUN " $rdm.Canonical_Name " ......."

$myesxcli.storage.core.device.setconfig($false,$rdm.Canonical_Name,$true)

$diskinfo = $myesxcli.storage.core.device.list($rdm.Canonical_Name) | Select -ExpandProperty IsPerenniallyReserved

$vmhost + " " + $rdm.Canonical_Name + " " + "IsPerenniallyReserved= " + $diskinfo

"----------------"

}

}

}

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try replacing that line with

   "$($vmhost.Name) $($rdm.Canonical_Name) IsPerenniallyReserved= $($diskinfo)"


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

Try replacing that line with

   "$($vmhost.Name) $($rdm.Canonical_Name) IsPerenniallyReserved= $($diskinfo)"


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

Reply
0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

That worked Champ... Thank you very much Smiley Happy

Reply
0 Kudos