# Создаём папку на рабочем столе
New-Item -ItemType Directory -Path "$env:USERPROFILE\Desktop\Scripts" -Force
# Создаём файл скрипта
@'
# Скрипт мониторинга сети
$devices = @("192.168.1.1", "192.168.1.10", "192.168.1.20")
foreach ($ip in $devices) {
if (Test-Connection -ComputerName $ip -Count 2 -Quiet) {
Write-Host "$ip - Доступен" -ForegroundColor Green
} else {
Write-Host "$ip - Недоступен" -ForegroundColor Red
}
}
'@ | Out-File -FilePath "$env:USERPROFILE\Desktop\Scripts\Monitor-Network.ps1" -Encoding UTF8