簡體   English   中英

以編程方式獲取Project Server項目的Project網站,在自定義字段中具有特定值

[英]Get Project Web Sites programmatically for Project Server Projects with specific value in a custom field

我正在使用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網站的方法。

據我所知,沒有公開Project Server數據的PS cmdlet。 而是必須通過PSI Web服務並使用ReadProjectList()方法。

我已經設法通過ReadProjectList()獲得了一個項目列表,但是無法確定它們是否為“活動”項目,也沒有找到與項目網站的直接鏈接。

我可以使用SharePoint cmdlet遍歷所有項目網站並在項目名稱上進行匹配,但這似乎不是最佳選擇,我仍然需要知道哪些項目處於“活動”狀態。

我發現了這一點,它使用上次修改的日期來確定它是否處於活動狀態。

#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() 
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM