modifying array element

This post was originally published on this site

I know its quite complicated, I have written some script to get the OnlineCapacityAnalytics|mem|recommendedSize key from VRA, basically this value gives recomended size but I need to put formulay if the size is above assigned mem then its undersize and if value below memory size then its overide, ( I have overide key in VRA key but that doesn’t give me accurate value)

 

 

$rec is array element it has VM,key,Average

$Vms is get-VM array

 

everything is works well but $_.key[0] not able to assigned as string value in array element

    

`powershell

                            

        foreach($VirtualMachine in $vms)

            {

             

               $rec | Where{$_.key -like “*OnlineCapacityAnalytics|mem|recommendedSize*”}| %{if($_.average -le ($VirtualMachine.MemoryMB*1kb)) {{$_.Key[0] = ” Overide”}}else{ {$_.Key[0] = “Undersize”}}}

               $subrec +=$Rec| ?{$virtualmachine.name -eq $_.VM -and $_.average -ne 0} | Select VM,@{N=”Cluster”;e={(Get-Cluster -vm $VirtualMachine).name}},@{N=”Site”;e={$site}},@{N=”PowerState”;e={($VirtualMachine).PowerState}},key,Average,time

            }

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.