title: Replace/rename object property name
body: <p>I need to replace “ip-netmask” with “fqdn” if dns resolution is successful.</p>
  
  <p>This script will be used to replace values in a config file.</p>
  
  <p>If DNS is resolved, I need to change the property name of “ip-netmask” to “fqdn” and store the new dns value under it. The script resolves DNS and only updates ip-netmask if successful, and is also adding an fqdn property with the DNS value if successful. </p>
  
  <p>Seems like I’m sort of there, but I am not able to rename ip-netmask to fqdn, or just delete the ip-netmask property without making my fqdn property null</p>
  
  <p>From original json input</p>
  
  <pre><code>
  @'
  {
      "entry":[
          {
              "@name":"31.170.162.203",
              "ip-netmask":"31.170.162.203",
              "description":"test1"
          },
          {
              "@name":"37.193.217.222",
              "ip-netmask":"37.193.217.222",
              "description":"test2"
          },
          {
              "@name":"46.17.63.169",
              "ip-netmask":"46.17.63.169",
              "description":"test3"
          }
      ]
  }
  </code></pre>
  
  <pre><code>
  $a = Get-Content 'C:\Users\e\Desktop\puttytest1.json' | ConvertFrom-Json
  
  
  
  $a.entry | ForEach-Object {
  
      if ($namehost = (Resolve-DnsName $_.'ip-netmask').namehost) {
  
          $_.'ip-netmask' = $namehost
  
          $_ | Add-Member -MemberType AliasProperty -Name fqdn -Value ip-netmask
  
          }
      }
  
  $newjson = $a | ConvertTo-Json
  
  $newjson
  
  </code></pre>
  
  <p>Output</p>
  
  <pre><code>
  {
  
      "entry":  [
  
                    {
  
                        "@name":  "31.170.165.68",
  
                        "ip-netmask":  "31.170.165.68",
  
                        "description":  "Test1"
  
                    },
  
                    {
  
                        "@name":  "31.170.162.203",
  
                        "ip-netmask":  "31.170.162.203",
  
                        "description":  "test2"
  
                    },
  
                    {
  
                        "@name":  "37.193.217.222",
  
                        "ip-netmask":  "l37-193-217-222.novotelecom.ru",
  
                        "description":  "test3",
  
                        "fqdn":  "l37-193-217-222.novotelecom.ru"
  
                    }
  
  ]
  
  }
  
  </code></pre>