Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIS ipSecurity: Added PowerShell example commands #541

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -179,3 +179,7 @@ The following code samples add two IP restrictions to the Default Web Site; the
### VBScript

[!code-vb[Main](add/samples/sample6.vb)]

### PowerShell

[!code-powershell[Main](add/samples/sample7.ps1)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Start-IISCommitDelay

$iisIpSecurity = Get-IISConfigSection -CommitPath 'Default Web Site' -SectionPath 'system.webServer/security/ipSecurity' | Get-IISConfigCollection
New-IISConfigCollectionElement -ConfigCollection $iisIpSecurity -ConfigAttribute @{ 'ipAddress' = '192.168.100.1'; 'allowed' = $false }
New-IISConfigCollectionElement -ConfigCollection $iisIpSecurity -ConfigAttribute @{ 'ipAddress' = '169.254.0.0'; 'subnetMask' = '255.255.0.0'; 'allowed' = $false }

Stop-IISCommitDelay
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,7 @@ The following code samples enble reverse DNS lookups for the default web site.
### VBScript

[!code-vb[Main](index/samples/sample7.vb)]

### PowerShell

[!code-powershell[Main](index/samples/sample8.ps1)]
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
$iisIpSecurity = Get-IISConfigSection -CommitPath 'Default Web Site' -SectionPath 'system.webServer/security/ipSecurity'

Set-IISConfigAttributeValue -ConfigElement $iisIpSecurity -AttributeName 'enableReverseDns' -AttributeValue $true