PowerShell - как проверить связь с конечными точками туннеля DirectAccess IPSec?

Приветствую собеседника!

Это мой первый вопрос после долгого ожидания. Я новичок в PowerShell, и в настоящее время я работаю над созданием сценария, который будет получать системную информацию, подключенные диски, конфигурацию сети и т. Д. Я хочу получить IPv6-адрес из DirectAccess. Конечная точка туннеля IPSec и эхо-запрос. Я бы хотел, чтобы вы могли пролить свет на это для меня, пожалуйста

Вот что у меня есть на данный момент:

##----------------------------------------------------------
## Variables
##----------------------------------------------------------
$Command = {[PSCustomObject]@{
    'computerSystem' = get-wmiobject Win32_ComputerSystem
    'computerMappedDrives' = Get-WmiObject -Class Win32_MappedLogicalDisk | Select-Object name,providername
    'computerEventErrorsApp' = Get-EventLog -LogName Application -EntryType Error -Newest 10 | Select-Object timegenerated,source,message 
    'computerEventErrorsSys' = Get-EventLog -LogName System -EntryType Error -Newest 10 | Select-Object timegenerated,source,message
    'computerDAClient' = Get-DAClientExperienceConfiguration
    'computerDAStatus' = Get-DAConnectionStatus
    'computerOfflineFiles' = Get-WmiObject -Class win32_OfflineFilesCache
}}
$data = Invoke-Command -ScriptBlock $Command

Logging -Text ("HOSTNAME              : " + $env:COMPUTERNAME) -LogFile $logfile
Logging -Text ("USER LOGGED IN        : " + $data.computerSystem.UserName) -LogFile $logfile
Logging -Text ("DIRECT ACCESS NAME    : " + $data.computerDAClient.FriendlyName) -LogFile $logfile
Logging -Text ("DIRECT ACCESS STATUS  : " + $data.computerDAStatus.Status) -LogFile $logfile
Logging -Text ("OFFLINE FILES         : " + ($data.computerOfflineFiles | Select-Object Enabled)) -LogFile $logfile

##----------------------------------------------------------
## Network Drives
##----------------------------------------------------------
foreach ($mappeddrive in $data.computerMappedDrives)
{    
    Logging -Text ("NETWORK DRIVES MAPPED : " + $mappeddrive.name + " -> " + $mappeddrive.providername) -LogFile $logfile
}

Write-Host "-NETWORK DRIVES COLLECTED-" -ForegroundColor Green

Это результат выполнения этой команды

$data.computerdaclient



Description                      : DA Client Settings
CorporateResources               : {HTTP:http://directaccess-WebProbeHost.xxx, HTTP:http://directaccess-webprobehost.xxx/}
IPsecTunnelEndpoints             : {PING:fd51:3db1:xxxx:xxxx::1, PING:fd51:3db1:xxxx:xxxx::2, PING:fd45:4035:xxxx:xxxx::1, PING:fd45:4035:xxxx:xxxx::2}
CustomCommands                   : 
PreferLocalNamesAllowed          : True
UserInterface                    : True
PassiveMode                      : False
SupportEmail                     : DA_support@xxxx
FriendlyName                     : Direct Access
ManualEntryPointSelectionAllowed : True
GslbFqdn                         :
ForceTunneling                   : Default

Есть идеи, как я могу извлечь значение из IPSecTunnelEndpoint и затем выполнить ping? Заранее спасибо! Ура, Гонсало


person gOnzzz    schedule 30.04.2020    source источник


Ответы (1)


Я думаю, что теперь у меня это работает:

(Get-DAClientExperienceConfiguration).IPsecTunnelEndpoints | ForEach-Object{

    If($_ -like '*PING:*'){
        $ipsec= $_.replace('PING:','')
        Write-Host ("TEST CONNECTION TO: " + $ipsec)
        Test-Connection $ipsec
    }
}

Результаты следующие:

TEST CONNECTION TO: fd45:4035:xxxx:1000::2

Pinging fd45:4035:xxxx:1000::2 with 32 bytes of data:
Reply from fd45:4035:xxxx:1000::2: time=6ms 
Reply from fd45:4035:xxxx:1000::2: time=9ms 
Reply from fd45:4035:xxxx:1000::2: time=13ms 
Reply from fd45:4035:xxxx:1000::2: time=14ms 

Ping statistics for fd45:4035:xxxx:1000::2:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 6ms, Maximum = 14ms, Average = 10ms
person gOnzzz    schedule 01.05.2020