ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 在PowerShell中操作SharePoint对象

在PowerShell中操作SharePoint对象

原创 Linux操作系统 作者:taogchan 时间:2013-09-06 15:21:42 0 删除 编辑

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. :)

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22392018/viewspace-772294/,如需转载,请注明出处,否则将追究法律责任。

上一篇: C# 静态类
请登录后发表评论 登录
全部评论

注册时间:2009-08-28

  • 博文量
    200
  • 访问量
    1191212