Home ยป PowerShell ยป New-WebSite in PowerShell

New-WebSite in PowerShell

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.

PowerShell New-Website
PowerShell New-Website

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.

Related Articles

Create a new web application

Remove website

Get all websites and applications in IIS

Check IIS Status

Get a List of Websites in IIS

Leave a Comment