頻繁部署 WSP 解決方案時,整理常用指令備查。SharePoint 2010 仍支援 STSADM,但官方建議改用 PowerShell,功能更強、效能更好、不區分大小寫,且必須以管理員身分在 SharePoint 伺服器上執行。
stsadm -o addsolution -filename c:\bin\CustomerSiteSearch.wsp
stsadm -o deploysolution -name CustomerSiteSearch.wsp -url https://[ServerName] -allowgacdeployment -force -immediate
stsadm -o activatefeature -name customersitesearch_feature1 -url https://[ServerName] -force
stsadm -o retractsolution -name solutionName.wsp -immediate
stsadm -o deletesolution -name solutionName.wsp
Add-SPSolution c:\bin\CustomerSiteSearch.wsp
Install-SPSolution -Identity CustomerSiteSearch.wsp -AllWebApplications -GACDeployment
Enable-SPFeature CustomerSiteSearch_feature1 -url https://[ServerName]/ -force
Uninstall-SPSolution -Identity solutionName.wsp
Remove-SPSolution -Identity solutionName.wsp
| 項目 | STSADM | PowerShell |
|---|---|---|
| 大小寫敏感 | 是 | 否 |
| 管線支援 | 無 | 完整物件管線 |
| 錯誤處理 | 回傳碼/文字 | 豐富例外物件 |
| 模組化 | 單一執行檔 | 模組化 Cmdlet |
| 官方建議 | 已棄用 | 標準工具 |
最佳實踐:新腳本一律使用 PowerShell;舊有 STSADM 腳本可逐步遷移。部署前請備份內容資料庫,並在測試環境驗證。