question

ErBoGuan-2779 avatar image
0 Votes"
ErBoGuan-2779 asked MotoX80 answered

IP Address and Domain Restriction by Powershell

I try to automatic a manual process in IIS. For one hour, we want to restrict all use to access one application. I search and test for today and cannot find a solution. Please help me out. All I need are at attached file. I just wonder if I can do it by Power Shells and schedule it instead of manually do it. Thank you.

202847-powershellhelp.pdf


windows-server-powershell
powershellhelp.pdf (38.9 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Consider adding the tag windows-server-iis to your original post.

0 Votes 0 ·
MotoX80 avatar image
0 Votes"
MotoX80 answered

Verify that you have the scripts and tools installed.

203279-capture.png


Add a deny entry.

203309-capture1.png


Open Configuration editor and navigate to system.webServer/security/ipSecurity. You should have count=1.Click on Edit Items.


203295-capture2.png


Make a trivial change to the ip address. Then close the popup.


203269-capture3.png


Then click on Generate Script. Copy the appcmd or Powershell statements from the Script Dialog popup.

203128-capture4.png



capture.png (19.7 KiB)
capture1.png (20.7 KiB)
capture2.png (47.0 KiB)
capture3.png (35.6 KiB)
capture4.png (51.1 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

Without knowing what you've already tried and failed at it's hard to know if anything anyone will recommend will be met with "already tried that!".

So, how about this: edit-an-existing-iis-ip-restriction-with-powershell


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ErBoGuan-2779 avatar image
0 Votes"
ErBoGuan-2779 answered ErBoGuan-2779 commented

Thanks for your quick response. I had tried that before and it seems not work for me?

What I need are:
(1) Go go IIS (local host) / the web application.
(2) "IP Address and Domain Restriction"
(3) Add "Deny Entry"
(4) "Specific IP Address"
(5) Enter "0.0.0.0"
(6) "OK"
(7) Remove the entry one hour later.

All these steps are manually do them now. I just wonder if I can use Powershell and schedule to do them?

· 4
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

So, you agree that not stating what you've already tried is actually an impediment to helping you arrive at a working solution? :-)

How about posting some of your failed attempts so we can avoid the "try this/already did that didn't work/etc." loop that is the usual thing we all see here. Maybe the problem isn't "it didn't work", but "you didn't do that in the right way"?

None of us here excel in Extra Sensory Perception.

0 Votes 0 ·
MotoX80 avatar image MotoX80 RichMatheisen-8856 ·

LOL.

Use the IIS configuration editor to generate the Powershell commands.

0 Votes 0 ·
ErBoGuan-2779 avatar image
0 Votes"
ErBoGuan-2779 answered RichMatheisen-8856 commented

I play around IIS configuration editor. But I cannot "Add Deny Entry" and enter "Specific IP Address"? (Please see the attachment). When I do it manually, I normally "Add Deny Entry" in an application and enter 0.0.0.0 as "specific ip address". But I cannot see they are available?
203278-powershellhelp2.pdf



powershellhelp2.pdf (12.4 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Aren't the IIS config files in XML format? If so, and you can't figure out how to use the IIS cmdlets to do this, why not just import the file and make the changes (saving it when you finish)?

0 Votes 0 ·
ErBoGuan-2779 avatar image
0 Votes"
ErBoGuan-2779 answered

We just do it for one application/site, not for whole IIS (all sites). I am looking for web configure file now.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.