14 lines
500 B
PowerShell
14 lines
500 B
PowerShell
|
|
$ErrorActionPreference = 'Continue'
|
||
|
|
Add-Type -Path 'C:\Program Files (x86)\Beckhoff\TwinCAT\3.1\Components\Base\v170\TwinCAT.Ads.dll'
|
||
|
|
foreach ($port in @(10000, 851)) {
|
||
|
|
try {
|
||
|
|
$c = New-Object TwinCAT.Ads.TcAdsClient
|
||
|
|
$c.Connect('169.254.176.217.1.1', $port)
|
||
|
|
$st = $c.ReadState()
|
||
|
|
Write-Host "port $port : AdsState=$($st.AdsState) DeviceState=$($st.DeviceState)"
|
||
|
|
$c.Dispose()
|
||
|
|
} catch {
|
||
|
|
Write-Host "port $port : ERR $($_.Exception.Message)"
|
||
|
|
}
|
||
|
|
}
|