Given a powershell script that uses New-WebApplication to create a web application in IIS:
New-WebApplication -Site "Default Web Site" -Name "Foo" -PhysicalPath "C:\websites\foo" -ApplicationPool "DefaultAppPool"
What is the equivalent command in IIS Administration?
IISAdministration was designed with a different philosophy to enable more C# style approach. So, when New-IISApplication
doesn't exist, you might use Get-IISServerManager
to get started,
Import-Module IISAdministration
$sm = Get-IISServerManager
$site = $sm.Sites["Default Web Site"]
$app = $site.Applications.Add("/Foo", "C:\websites\foo")
$app.ApplicationPoolName = "DefaultAppPool"
$sm.CommitChanges()