(למרות זה...)
צ'אטGPT מציע לי את זה
# Define the URL of the CSV file
$csvUrl = "https://www.nirsoft.net/countryip/il.csv"
# Download the CSV file content
$csvContent = Invoke-WebRequest -Uri $csvUrl -UseBasicParsing | Select-Object -ExpandProperty Content
# Convert the CSV content to objects
$ipRanges = $csvContent | ConvertFrom-Csv -Delimiter "`t" -Header "StartIP", "EndIP", "Size", "Date", "Company"
foreach ($range in $ipRanges) {
$startIP = $range.StartIP
$endIP = $range.EndIP
$company = $range.Company
# Create a firewall rule for the IP range
New-NetFirewallRule -DisplayName "Allow $company $startIP-$endIP" -Direction Inbound -Action Allow -RemoteAddress "$startIP-$endIP"
}
Write-Output "Firewall rules have been created successfully."
אני לא יושב על ווינדוס כרגע ולא בדקתי שזה עובד, אבל לפום ריהטא זה נראה הגיוני
צריך גם להגדיר שברירת המחדל יהיה לחסום.
משהו כזה:
Set-NetFirewallProfile -DefaultInboundAction Block -DefaultOutboundAction Allow