在PowerShell中操作SharePoint对象

1.用PowerShell创建一个SharePoint内容对象创建一个自定义列表:
$SPSite = New-ObjectMicrosoft.SharePoint.SPSite("http://inno");
$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("http://inno");
$OpenWeb = $SpSite.OpenWeb();
$OpenWeb.ListTemplates | Select Name, Description;
$OpenWeb.Dispose();
$SPSite.Dispose()


3. 如何用PowerShell导出/备份SharePoint站点You need something like this:
Get-SPWeb -sitehttp://sp2010  | ForEach-Object { $filename = $_.Url.replace("http://","").replace("-","--").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 likehttp://sp2010/sites/test/foo-barwill 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. :)

请使用浏览器的分享功能分享到微信等