Issue Splitting DNSServerSearchOrder results and sending to SQL DB

Home Forums Scripting Windows Script Host Issue Splitting DNSServerSearchOrder results and sending to SQL DB

Viewing 1 post (of 1 total)
  • Author
    Posts

  • XIIxOveR
    Member
    #152155

    Hi there,

    Hopefully I can explain this well enough so that it makes sense. I’m relatively new to VBScript which will probably be quite evident in this, my first post here.

    I am trying to capture the value of DNSServerSearchOrder from servers listed in an input file. I then want to write the primary, secondary, and tertiary values out to three seperate columns in a SQL database. Where I’m having trouble is sometimes a server may correctly have all three values whereby sometimes it will only have one or two values.

    Function ReportDnsWins(DeviceName)
    Dim objWMIService, colCards, objCard, strDNSServerSearchOrder, strDNSServers
    Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\” & DeviceName & “rootcimv2”)
    Set colCards = objWMIService.ExecQuery(“Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True”)
    For Each objCard in colCards
    strDNSServerSearchOrder = Join(objCard.DNSServerSearchOrder, “,”)
    strDNSServers = split(strDNSServerSearchOrder, “,”)
    Call Write2DB(DeviceName, strDNSServers(0), strDNSServers(1), strDNSServers(2), objCard.WINSPrimaryServer, objCard.WINSSecondaryServer)
    Next
    End Function
    [/CODE]

    So this works great if the strDNSServers array ends up populated with three values from the split, however this will give an “out of range”, of course, for servers with only one or two values. If it’s anything over three I don’t care, I only care about the first three.

    This also works great if I want to keep it simple and output the entire value of DNSServerSearchOrder to a single column in SQL thus tracking the entire list of DNS servers in the column and sorting the results of the query in Excel or something rather than using the transact SQL query itself. But this seems like it should be simple enough so I can’t let it go!

    Definitely open to any insight, it would take me a bit to explain everything I’ve tried so far but if it helps I’ll try. Hopefully someone can help me think the logic through here, I’m probably missing something simple.

    Thanks!

    X[CODE]
    Function ReportDnsWins(DeviceName)
    Dim objWMIService, colCards, objCard, strDNSServerSearchOrder, strDNSServers
    Set objWMIService = GetObject(“winmgmts:” & “{impersonationLevel=impersonate}!\” & DeviceName & “rootcimv2”)
    Set colCards = objWMIService.ExecQuery(“Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True”)
    For Each objCard in colCards
    strDNSServerSearchOrder = Join(objCard.DNSServerSearchOrder, “,”)
    strDNSServers = split(strDNSServerSearchOrder, “,”)
    Call Write2DB(DeviceName, strDNSServers(0), strDNSServers(1), strDNSServers(2), objCard.WINSPrimaryServer, objCard.WINSSecondaryServer)
    Next
    End Function
    [/CODE]

    So this works great if the strDNSServers array ends up populated with three values from the split, however this will give an “out of range”, of course, for servers with only one or two values. If it’s anything over three I don’t care, I only care about the first three.

    This also works great if I want to keep it simple and output the entire value of DNSServerSearchOrder to a single column in SQL thus tracking the entire list of DNS servers in the column and sorting the results of the query in Excel or something rather than using the transact SQL query itself. But this seems like it should be simple enough so I can’t let it go!

    Definitely open to any insight, it would take me a bit to explain everything I’ve tried so far but if it helps I’ll try. Hopefully someone can help me think the logic through here, I’m probably missing something simple.

    Thanks!

    X

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.

External Sharing and Guest User Access in Microsoft 365 and Teams

This eBook will dive into policy considerations you need to make when creating and managing guest user access to your Teams network, as well as the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure.

You will learn:

  • Who should be allowed to be invited as a guest?
  • What type of guests should be able to access files in SharePoint and OneDrive?
  • How should guests be offboarded?
  • How should you determine who has access to sensitive information in your environment?

Sponsored by:

 
Office 365 Coexistence for Mergers & Acquisitions: Don’t Panic! Make it SimpleLive Webinar on Tuesday, November 16, 2021 @ 1 pm ET

In this session, Microsoft MVPs Steve Goodman and Mike Weaver, and tenant migration expert Rich Dean, will cover the four most common steps toward Office 365 coexistence and explain the simplest route to project success.

  • Directory Sync/GAL Sync – How to prepare for access and awareness
  • Calendar Sharing – How to retrieve a user’s shared calendar, or a room’s free time
  • Email Routing – How to guarantee email is routed to the active mailbox before and after migration
  • Domain Sharing – How to accommodate both original and new SMTP domains at every stage

Aimed at IT Admins, Infrastructure Engineers and Project Managers, this session outlines both technical and project management considerations – giving you a great head start when faced with a tenant migration.the different layers of guest access and the common challenges that accompany a more complicated Microsoft 365 infrastructure.

Sponsored by: