appcmd.exe causes IIS service to drop

84 Views Asked by At

I am using appcmd.exe to add IP addresses to the ipSecurity module of IIS. I am using a very basic Powershell script which reads a list from a web service of no more than 10-20 IPs, and I am adding those into the ipSecurity. I then run my Powershell through Task Scheduler, every 5 minutes to keep this list updated.

The command I am using via Powershell to add the IPs is

& $appcmd set config -section:system.webServer/security/ipSecurity /+"[ipAddress='$ip_address',subnetMask='$subnet_address',allowed='False']" /commit:apphost | Out-null

Perhaps it's important to say that on every execution of my Powershell, I am clearing first this list entirely using this command.

& $appcmd clear config /delete:true /section:system.webServer/security/ipSecurity /commit:apphost | Out-null

and then I add the new, updated IP list.

When I do this, I have noticed that the IIS service may drop. It does not happen always. But sometimes it does. When I stop the scheduler my IIS service works like a charm.

Any help? I couldn't find anything related at the Microsoft pages to be honest.

thank you

0

There are 0 best solutions below