title: how to extend partition remotely for a virtual machine using powershell
body: <p>I have attempted to write a Powershell script to remotely extend a partition of a virtual machine. I have added 1gb to the existing C drive which would make it 81GB on the VDI but I deliberately did not extended it as I want to do it by this script.</p>
  
  <p>Any ideas of what I am doing wrong as I would like to run it on a group machines which a list resides in the text file:</p>
  
  <pre><code>$servers = Get-Content 'C:\MININT\Computers.txt'
  $GlobalResults = @()
  $ConvertToGB = ( 1024 * 1024 * 1024 )
  ForEach ($server in $servers)
  {
      $disk = get-wmiobject win32_LogicalDisk -ComputerName $server -Filter "DeviceID='C:'" | Select-object size,Freespace    
  $server + "," + ($disk.size / $ConvertToGB) + "," + ($disk.Freespace / $ConvertToGB)    
  $MaxSize =  (Get-PartitionSupportedSize -DriveLetter c).sizeMax
      Resize-Partition -DriveLetter c -Size $MaxSize
  }
  </code></pre>
  
  <p>Any assist would be greatly appreciated as I am a beginner on this.</p>
  
  <p>Kind regards</p>