convert to array

Клим Бутунин 96 Reputation points
2021-03-23T18:17:08.067+00:00

Hi guys!
Please forgive me for my English.

I have a DirectAccess Server.
I need to unload from Get-RemoteAccessConnectionStatistics | select HostName, ClientIPv6Address
Value.
And then write the data to the dns server.

In the output, I get something like this (name and AAAA(ipv6)):

HostName              ClientIPv6Address
--------              -----------------
123\NB6835$           fde4:7614:cdf1:1000:75c6:34f8:5de9:e018
host/NB6300.123.local fde4:7614:cdf1:1000:10a4:cd0:3874:212f
host/NB3437.123.local fde4:7614:cdf1:1000:e4c6:de90:12e4:a61d
123\NB6867$           fde4:7614:cdf1:1000:140e:ce4a:2b28:416f
123\NB6333$           fde4:7614:cdf1:1000:68f9:2616:957f:3e86
host/nb6272.123.local fde4:7614:cdf1:1000:4c7f:f58e:7f3d:2476
123\NB6300$           fde4:7614:cdf1:1000:3464:86df:16a4:10
123\NB6849$           fde4:7614:cdf1:1000:35a1:dba0:a72:d2a7
123\NB3582$           fde4:7614:cdf1:1000:8c32:4c88:67d9:ffd1

I don’t understand how to make a split and substitute these values in

add-DnsServerResourceRecord -ComputerName dune -ZoneName 123.local -Name ws6872 -IPv4Address fde4:7614:cdf1:1000:887a:c6ad:bf73:2cf1 -AllowUpdateAny -WhatIf

Help implement this with a pipeline

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. Клим Бутунин 96 Reputation points
    2021-03-23T19:18:45.997+00:00

    So ... figured out

      $letters = Get-RemoteAccessConnectionStatistics | select HostName , ClientIPv6Address
         foreach($letter in $letters)
         {
         if ($letter.HostName -like '*host*')
         {
         $name1=$letter.HostName.split('/')
    
         $name2=$name1[1].split('.')
         Add-DnsServerResourceRecordAAAA -ComputerName dune -ZoneName 123.local -Name $name2[0] -IPv6Address $letter.ClientIPv6Address -AllowUpdateAny -Confirm:$false
    
    
    
    
         }
         else
         {
         $name=$letter.HostName.split('\')
        $name1=$name.split('$')
        Add-DnsServerResourceRecordAAAA -ComputerName dune -ZoneName 123.local -Name $name1[1] -IPv6Address $letter.ClientIPv6Address -AllowUpdateAny -Confirm:$false
    
         }
         }
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.