Share via

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 for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Rich Matheisen 48,116 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?

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.