PowerShell is very much useful in SharePoint 2010. First we will discuss PowerShell to create a new web application.
PowerShell Command to Create a New Web Application:
SPWebApplication is responsible for creating a new
web application in PowerShell.
New-SPWebApplication –applicationpool <Application pool name> -name <Web app name>
-applicationpoolaccount <service account for the application pool> -port <port number>
Example:
New-SPWebApplication –applicationpool SharePoint-80 -name SharePoint-80 -applicationpoolaccount SP2010\Administrator -port 80
PowerShell Command to Create a New Site Collection (Top Level Site):
New-SPSite –url <full url of new site collection>
-name <name of new site collection>
-owneralias <site collection administrator>
-template <site collection template to use>
Example:
New-SPSite –url http://enjoysharepoint/ -name Home -owneralias SP2010\Administrator -template STS#0
PowerShell Command to Create a New Sub Site:
SPWeb is responsible for creating a sub site.
New-SPWeb –url <full url of new site> -name <name of new sub site> -template <site template to use>
Example:
New-SPWeb –url http://enjoysharepoint/TestSubSite -name "Test Sub Site" -template STS#0
You can also check SharePoint 2010 powershell commands
here.