title: rename hostname using powershell script
body: <p>I am cloning an instance using golden image in AWS and I am trying to rename the instance using the IP address. The thing is I can clone and the variable $ipaddress contains the corresponding IP address, but I'm unable to get the hostname.</p>
  
  <pre><code>foreach ($key in $SystemTypes.Keys) {
    [String]$value = $SystemTypes[$key]
  
      #$value = $($SystemTypes[$key])
      $ipaddarray = $value.split('.')
  
      $ipaddress = $ipaddarray[0]+'.'+$ipaddarray[1]+'.'+$ipaddarray[2]+'.'+$ipaddarray[3]    
  
      Write-Host "the type is $key"
      Write-Host "the ip is  $ipaddress"
      Write-Host $value
      $object = Get-WmiObject -Class win32_operatingsystem -ComputerName $ipaddress -Credential $MylocalCreds    
       $hostname = $object.__server
  </code></pre>