How to block IP Adresses using PowerShell Scripts from specific file?

Anonymous
2020-12-08T19:37:02.507+00:00

Hello,
for testing we want to block logging IPS on our windows server.

How we manage using PowerShell?

The file (txt file) contains the ip adresses like this:
"blah": false, "LoggingServerAddresses": "10.0.20.132,10.0.20.133", "blah": false,

We want all IPS in LoggingServerAddresses get blocked

Thanks for any help :)

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,205 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 45,096 Reputation points
    2020-12-08T20:07:12.817+00:00

    This isn't an answer, but the text is too long to post as a comment!

    Your question is a bit confusing. Is your intention to "block logging IPS" (as you say in your first sentence), or is it to block IP addresses?

    If you're trying to block IP addresses, are you including the entire server (i.e. using a firewall), for a web site (i.e. IIS), for email (e.g. Exchange), or some combination of those?

    In your description of the text file you have some data surrounded by quotes, and some not within quotes. The example shows the string "LoggingServerAddresses" with quotes, and some IPv4 addresses with quotes. Yet you say that there are "IPS in LoggingServerAddresses". Does this mean that "LoggingServerAddresses" is a literal string of characters, or with there be IP addresses where you currently show the string "LoggingServerAddresses"? Or are the fields in the text file in the format "Label: Value" and each pair is separated from the next by a comma?

    Is the text file in the format of a Comma Separated Values file? If it is, are there more fields that follow the trailing comma in your example?