Skip to content

Enhancement: Update Single NSG Rule with IP's from mulitpule FQDN #2

Open

Description

Would it be possible to update a Single NSG Rule with IP's from mulitpule FQDN's?

Activity

  1. captainhook commented on Jul 8, 2020

    @captainhook
    Owner

    It would very much be possible. In our IPLookup script we'd need to build and output and array.

    I'll have a go at it this weekend but it would look something like this:

    $NameList = @('host1.com','host2.com','host3.com')
    $ServerList = @('1.1.1.1','1.0.0.1')
    
    $FinalResult = @()
    foreach ($Name in $NameList) {
        $tempObj = "" | Select-Object IPAddress
        try {
            $dnsRecord = Resolve-DnsName -Name $Name -Server $ServerList -Type A -DnsOnly -ErrorAction Stop | Where-Object {$_.Type -eq 'A'}
            $tempObj.IPAddress = ($dnsRecord.IPAddress -join ',')
        }
        catch {
            $tempObj.IPAddress = ''
        }
    
        $FinalResult += $tempObj
    }
    return $FinalResult
    

    Adapted from @devbyaccident's work, https://adamtheautomator.com/resolve-dnsname/

  2. captainhook commented on Jul 8, 2020

    @captainhook
    Owner

    If you figure it out in the meantime, a pull request is welcome 😄

  3. captainhook commented on Aug 7, 2020

    @captainhook
    Owner

    Please drop your email in the 'request contact' section of https://node15.com/ towards the footer and I'll get in touch :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions