- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Updating a host record via powershell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-07-2019 09:37 AM
I am trying to update a host record IPv4 address with script.
The script returns error. Invoke-RestMethod : Unable to connect to the remote server.
$Body = @{
"@type" = "login"
"username" = "crailey@xx.org"
"password" = "pass!"
} | ConvertTo-Json
$header = @{
"Accept"="application/json"
"connectapitoken"="97fe6ab5b1a640909551e36a071ce9ed"
"Content-Type"="application/json"
}
Invoke-RestMethod -Uri "10.10.0.2" -Method 'Post' -Body $body -Headers $header | ConvertTo-HTML
Invoke-Command -Computername 'ns3.mlgw.org' -scriptblock {
$oldobj = get-dnsserverresourcerecord -name "10.5.6.56" -zonename "ad.xx.org" -rrtype "A"
$newobj = get-dnsserverresourcerecord -name "10.1.2.156" -zonename "ad.xx.org" -rrtype "A"
$updateip = "10.1.2.0"
$newobj.recorddata.ipv4address=[System.Net.IPAddress]:arse($updateip)
Set-dnsserverresourcerecord -newinputobject $newobj -oldinputobject $oldobj -zonename "ad.mlgw.org" - passthru
}
Does my code look correct to update host x ip with a new ip.
Re: Updating a host record via powershell
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2019 09:29 PM
The address is stored in the host address record, not in the host record. You will first need to locate the host address record, and update the address there.
Also the URI should be a REST endpoint, not just an IP address. for example 'https://10.10.0.2/wapi/v2.4/request'