- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Powershell: Add Host with MAC and enabled DNS
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2024 04:54 AM - edited 01-05-2024 04:57 AM
Hello everyone,
I have been working on this problem for several days now and have not yet found a solution. I have looked at all the modules I know of and unfortunately I just can't get any further. I would therefore be extremely grateful for help. Here is my situation:
I create a VM using a PowerShell script. I then want to assign it an IP using its MAC address. This works so far, but I need DHCP and DNS to be active in our company. When I create the HostRecord, DHCP is already activated. However, DNS is missing.
The final configuration should look like this:
I don't know how to activate DNS and also pass the corresponding zone. I am including my previous script. I would really be infinitely grateful if anyone has a solution for this. Thank you very much!
Code:
$pwd = ConvertTo-SecureString "PW" -AsPlainText -Force $Credential = New-Object Management.Automation.PSCredential ('ID', $pwd) $GridServer = "SERVER" $network = "REF" $IPv4Address = Get-IBNextAvailableIP -GridServer $grid -Credential $cred -NetworkRef $network $HostName = "NAME" $Comment = "COMMENT" $apiVersion = "2.10.5" $uri = "https://$grid/wapi/v$apiVersion/record:host" $dns = $true $data = @{ ipv4addrs = @( @{ ipv4addr = $IPv4Address mac = "00:50:56:88:89:35" } ) name = $HostName comment = $Comment.Trim() configure_for_dns = $dns } $json = $data | ConvertTo-Json Invoke-RestMethod -Uri $uri -Method Post -Body $json -ContentType 'application/json' -Credential $Credential
Re: Powershell: Add Host with MAC and enabled DNS
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2024 03:08 PM
The value of "name" needs to be an FQDN, in an existing zone to configure the host record for DNS. For example, if you want a DNS record in the zone mycompany.com, pass a value of name.mycompany.com.