在PowerShell中操作SharePoint物件

taogchan發表於2013-09-06

1.用PowerShell建立一個SharePoint內容物件建立一個自定義列表:
$SPSite = New-ObjectMicrosoft.SharePoint.SPSite("");
$OpenWeb = $SpSite.OpenWeb();
$TemplateType = $OpenWeb.ListTemplates["自定義列表"];
$OpenWeb.Lists.Add("My Custom List2","Description Of My Custom List",$TemplateType);
$OpenWeb.Dispose(); $SPSite.Dispose()


2.用PowerShell列出站點所有Content模板
$SPSite = New-ObjectMicrosoft.SharePoint.SPSite("");
$OpenWeb = $SpSite.OpenWeb();
$OpenWeb.ListTemplates | Select Name, Description;
$OpenWeb.Dispose();
$SPSite.Dispose()


3. 如何用PowerShell匯出/備份SharePoint站點You need something like this:
Get-SPWeb -site | ForEach-Object { $filename = $_.Url.replace("","-") + ".export" ;
Write-Host export-spweb $_ -path $filename}That will walk through all the webs under sp2010,
remove the "http://" at the beginning, replace all the dashes with doubledashes,
and the slashes with dashes. Then exports them.
That way something like be savesd as sites-test-foo--bar.export.Oh,
and you'll have to remove the "write-host" for it to actually work. I put that in as a safety measure. :)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22392018/viewspace-772294/,如需轉載,請註明出處,否則將追究法律責任。

相關文章