The PowerShell command to create a new website in the IIS server is New-WebSite
`. The New-WebSite command creates an IIS website with the settings specified in the parameter values.
The New-WebSite cmdlet syntax is given below.
New-Website
[-Name] <String>
[-Id <UInt32>]
[-Port <UInt32>]
[-IPAddress <String>]
[-SslFlags <Int32>]
[-HostHeader <String>]
[-PhysicalPath <String>]
[-ApplicationPool <String>]
[-Ssl]
[-Force]
[<CommonParameters>]
The New-WebSite cmdlet is available in the PowerShell WebAdministration module.
In this article, we will discuss how to create a new website in an IIS server using the PowerShell New-WebSite cmdlet.
How to Create a Website in an IIS Server
The New-WebSite
cmdlet in PowerShell creates a website in an Internet Information Services (IIS) server. The command uses the settings specified in the parameter values to create and configure a website.
New-WebSite -Name "MyAppSite" -Port 80 -HostHeader "MyAppSite" -PhysicalPath "C:\inetpub\wwwroot\myappsite"
In the above PowerShell script, the New-Website
creates a new website named “MyAppSite” that runs on port 80, and website files are physically located at “C:\inetpub\wwwroot\myappsite“.
The Name
parameter specifies the name of the new website.
The Port
parameter specifies the port of the site.
The PhysicalPath
parameter specifies the path of the new sites.
The HostHeader
parameter specifies the host header of the new site.
The output of the above PowerShell script creates a new website in the IIS server as given below.
Conclusion
I hope the above article on how to create a new website in an IIS server using the PowerShell New-WebSite cmdlet is helpful to you.
You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.