powershell - Invoke-Command 阻止辅助网络上的连接
问题描述
我有2台电脑。一种是连接到互联网的数据服务器。此数据服务器每小时将 TimeSync 脚本推送到未连接到 Internet 的其他计算机。所以基本上,它们都是通过以太网连接的,但只有数据服务器根据在线数据知道当前时间。第二台计算机是计算机 B。
所以这就是问题所在。
计算机 B 有 2 个网卡。一个与数据服务器通信,一个与 PLC(可编程逻辑控制器)通信。并且每当 TimeSync 脚本运行时,计算机 B 和 PLC(网卡 #2)之间的通信都会在脚本执行期间受到干扰,不会在 Windows 注册表中提供任何错误。
网络 1 (A) : 200.200.200.X 网络 B (PLC) : 150.150.150.X
我检查了多个网站,我几乎没有发现任何东西。
$pingtimeout = 5
$buffersize = 16
#Filter for ping response, allowing to pass ping parameters, unavailale through Test-Connection (Ping Timeout for example)
filter Invoke-FastPing {(New-Object System.Net.NetworkInformation.Ping).send($_,$pingtimeout,$buffersize)}
#Sweeping the network
foreach($num in 1..254)
{
if("200.200.200.$num" | invoke-fastping | Where-Object status -eq 'success')
{
#Set time for each computer
$time = get-date
$output = Invoke-Command 200.200.200.$num {set-date $using:time} -ArgumentList $time
if ($output -ne $null)
{
Start-Process -WindowStyle hidden -FilePath PowerShell.exe -Verb Runas -ArgumentList "Write-EventLog -LogName System -Source 'Timesync Script' -EntryType Information -EventId 1 -Message 'Time update on 200.200.200.$num'"
$output = Invoke-Command 200.200.200.$num {New-EventLog -LogName System -Source "Timesync Script"}
$output = Invoke-Command 200.200.200.$num {Write-EventLog -LogName System -Source "Timesync Script" -EntryType Information -EventId 1 -Message "Time was updated"}
}
}
}
如果一切正常,很好,时间应该正确地推送到计算机上,并且 PLC 不会出现通信问题。
解决方案
我想通了,似乎是时间脚本将时间推过去的时候发生的。通讯似乎是在等待时间到达某个时间才能恢复。
例如:如果时间倒退 10 秒,通信程序将等待 10 秒再恢复。
推荐阅读
- javascript - request.form.get 返回 None 而不是 input
- php - XAMPP 错误:Apache 意外关闭
- sql-server - SQL Server Management Studio 中的 SQL 查询出现问题。在具有远程访问权限的服务器上工作
- python - 在许多不同的类中编写 map 和 reduce?
- python - 有没有办法在 Altair boxplot 中格式化工具提示值
- prolog - 查找列表中唯一元素的数量
- php - 如何将 PHP 数组发送到电子邮件/短信并维护数组中文本的格式?
- java - 类型不匹配,java spring & hibernate,无法将 mySQL 数据库的数据从 Object 转换为 String
- laravel - PhpStorm 找不到 findOrFail() 方法
- python - 迭代 Dataframe 列以绘制直方图