1 Reply Latest reply on Apr 6, 2020 7:53 AM by jpsider

    If condition not working

    Vel_VMware Enthusiast

      Hi,

       

      I am trying to create one small script to check datastore utilization percent, but if condition is not working. Can any one help me on this.

       

      Connect-VIServer -Server VC001

      $size = Get-Datastore -Name Datastore001 | Select-Object name, @{name="CapacityGB";Expression={[math]::Round($_.capacitygb,2)}}, @{name="FreeSpaceGB";Expression={[math]::Round($_.freespacegb,2)}}, @{name="PercentFree";Expression={[math]::Round(($_.freespacegb / $_.capacitygb * 100),2)}}

      If(percentFree -gt 50)

      {

      'Datastore freespace is morethan 50%'

      }

      else

      {

      'Datastore  freespace is lessthan 50%'

      }

       

      Thanks in advance