I am a big fan of PowerShell and have been looking for ways to script out common IIS Administration tasks using PowerShell and there have been a number of methods provided in the past that made it reasonably difficult to create Web Applications in IIS using PowerShell.
However, I came across an article recently that makes this task a piece of cake! https://technet.microsoft.com/en-us/library/hh867877(v=wps.630).aspx
This resulted in me creating the following PowerShell script:
This worked like a charm! Now I can easily automate nearly any IIS Administration task! Woo hoo!
However, I came across an article recently that makes this task a piece of cake! https://technet.microsoft.com/en-us/library/hh867877(v=wps.630).aspx
This resulted in me creating the following PowerShell script:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param | |
( | |
[Parameter(Mandatory=$true)] | |
$AppPoolName = "DefaultAppPool", | |
[Parameter(Mandatory=$true)] | |
$WebAppName, | |
[Parameter(Mandatory=$true)] | |
$WebsiteName = "Default Web Site", | |
[Parameter(Mandatory=$true)] | |
$PhysicalPath | |
) | |
Clear-Host | |
#create the Physical Path if it does not already exist | |
$DirExists = Test-Path $PhysicalPath | |
if ($DirExists -ne $true) | |
{ | |
New-Item -Path $PhysicalPath -ItemType Directory | |
}#if | |
#Create the new Web Application | |
New-WebApplication -Name $WebAppName -Site $WebsiteName -PhysicalPath $PhysicalPath -ApplicationPool $AppPoolName |
This worked like a charm! Now I can easily automate nearly any IIS Administration task! Woo hoo!
No comments:
Post a Comment