0

我正在使用 Microsoft Project Server 2010,我需要批量更新与活动项目关联的项目网站 (PWS) 中的一些 SharePoint 列表。

如果项目状态自定义字段具有某些特定值,则项目被视为“活动”。

类似于以下伪代码:

Get-AllProjectServerProjects | 
  Where-Object { ($_.CustomFields["Project Status"]) -eq 'active' } |
  Foreach-Object {
    $projectWebSite = $_.ProjectWebSiteURL

    # Code here to update SharePoint list for this site

  }

我已经有了更新 SharePoint 列表的代码,我正在寻找一种让项目网站与“活动”项目相关联的方法。

据我所知,没有公开 Project Server 数据的 PS cmdlet。相反,必须通过 PSI Web 服务并使用 ReadProjectList() 方法。

我设法通过 ReadProjectList() 获得了项目列表,但无法判断它们是否是“活动”项目,并且我没有设法找到指向项目网站的直接链接。

我可以使用 SharePoint cmdlet 遍历所有项目网站并匹配项目名称,但这似乎不是最优的,我仍然需要知道哪些项目是“活动的”。

4

1 回答 1

0

我发现了这个,它使用最后修改日期来确定它是否处于活动状态。

#Set-ExecutionPolicy RemoteSigned
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
$url="http://sharePoint.company.com"
$site = New-Object Microsoft.SharePoint.SPSite($url)
$spWebApp = $site.WebApplication

$OutputFN = "c:\ActiveSitesReport.csv"
"Site Name `t URL `t Last Modified" > $OutputFN

# Iterate through all sites:
foreach ( $spSite in $spWebApp.Sites )
{
     foreach ($spWeb in $spSite.AllWebs)
    {
              if ($spWeb.IsRootWeb)
              {
                $siteName = $spWeb.Title +" - Root";
              }
              else
              {
              $siteName = $spSite.RootWeb.Title + " - " + $spWeb.Title;
              }                           
           $siteName + "`t" + $spWeb.Url + "`t" + $spWeb.LastItemModifiedDate >> $OutputFN
         $spWeb.Dispose() 
    }
$spSite.Dispose() 
}
于 2016-08-22T05:16:31.500 回答