標籤:sharepoint 2010 powershell 網站
使用PowerShell 建立SharePoint 網站 在SharePoint開發中,你應該學會使用PowerShell管理SharePoint網站。SharePoint Management Shell是一個Windows PowerShell模組,你可以用它高效管理SharePoint 使用者、網站、網站集合和組織。 這裡教你簡單的語句,建立一個SharePoint網站。 輸入一下語句。紅色框內資訊是按下Enter後出現的。
建立的網站如下:
首先我們需要理解如何使用PowerShell建立網站。new-spweb這一特殊命令只有一個必要元素,即網站的URL,但是也有許多其他參數,在建立網站時使用可以豐富網站資訊。-url:新建立網站的URL。-template: 添加模板號。-name: 顯示網站名稱。-AddToTopNav: 是否要網站顯示在頂部導覽列。-UseParentTopNav:是否要網站使用父網站的導航。 經測試,支援漢字網站名稱。 關於SharePoint 2010 網站模板名稱與ID的對應,請查看http://blogs.msdn.com/b/richin/archive/2011/07/04/sharepoint-2010-site-template-names.aspx 如果你不確定哪些模板是可用的,你可以使用Get-SPWebTemplate返回可用模板的列表。
補充建立新的Web應用程式New-SPWebApplication -Name <name>-HostHeader <hostheader> Port <port> -Url<url> -ApplicationPool <application pool> -ApplicationPoolAccount <applicationpoolaccount> –DataBaseName <databasename>
------------------------------------分割線----------------------------------------New-SPWebApplication -Name “Company Intranet” -HostHeader “intranet.company.com”-Port 80 -Url “http://intranet.company.com:80” -ApplicationPool “SharePoint Web Applications” -ApplicationPoolAccount (Get-SPManagedAccount “CompanySP_Service”) -DatabaseName “WSS_Content_Intranet”
刪除Web應用程式Remove-SPWebApplication http://intranet.company.com -DeleteIISSite -RemoveContentDatabase -Confirm:$false
建立內容資料庫New-SPContentDatabase -Name<ContentDBName> -WebApplication <WebApplicationName>
------------------------------------分割線----------------------------------------
New-SPContentDatabase -Name WSS_Content_Intranet_Sales -WebApplication http://intranet.company.com
建立網站集合New-SPSite -URL “<URL for the new site collection>” -Name <name> -ContentDatabase <content database name> -OwnerAlias “<domainuser>” -Template <template>
------------------------------------分割線----------------------------------------
New-SPSite -URL “http://intranet.company.com/sites/sales” -Name “Sales” -ContentDatabase WSS_Content_Intranet_Sales -OwnerAlias “COMPANYSPAdmin” -Template “STS#0″ 以上也不是什麼新的知識,在其他地方你也可以看到。我這裡總結一下,只是為了以後需要的時候,能夠很快地引用它們。