How to set IP Address Restrictions for Management Service in IIS through PowerShell?

360 views Asked by At

I'm looking for a way to script the whole IIS configuration through PowerShell and I've already done most of it. The problem I'm facing right now is how to set 'IP Address Restrictions' for Management Service in IIS. I know there is a simple way to do it for a domain or a site but my goal is to limit the number of IP's being able to deploy to IIS.

Including screenshot for clarification: IIS Management Service

1

There are 1 answers

0
lis On

Following @BruceZhang advice, I've firstly set up the required value using the UI, then looked up the registry 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WebManagement\Server\RemoteRestrictions' and found out the encrypted value for my ip address. From now on setting it up was only a matter of changing the value for this key in the registry through PowerShell script. It works fine, thanks!

Stop-Service -Name "WMSVC"

Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WebManagement\Server" -Name "RemoteRestrictions" -Value /wEZAgAAAAEAAABnAgAAABkBAAAAAAAAABkDAAAAAQAAAC4EA8ADqAMdAx0CAAAALgQD/wP/A/8D/wMAAAB

Start-Service -Name "WMSVC"