0

I'm using Microsoft Project Server 2010 and I need to bulk update some SharePoint lists in the the Project Web Sites (PWS) associated with active Projects.

Projects are deemed to be 'active' if the Project Status custom field has some specific values.

Something like the following pseudocode:

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

    # Code here to update SharePoint list for this site

  }

I already have code to update the SharePoint lists, what I'm looking for is a way to get the Project Web Sites associated with 'active' projects.

As far as I can tell, there are no PS cmdlets that expose Project Server data. Rather, it is necessary to go via the PSI web service and use the ReadProjectList() method.

I've managed to get a list of projects via ReadProjectList() but cannot tell if they are 'active' projects and I've not managed to find a direct link to a project web site.

I could iterate through all the project web sites by using the SharePoint cmdlets and match on the project name, but this does not seem optimal and I still need to know which projects are 'active'.

andyb
  • 2,722
  • 1
  • 18
  • 17
  • There is a way of getting the Workspace URL from the Project UID. The ReadWssInfo method of the WssInterop web service returns a ProjectWSSInfoDataSet object that includes the Project Web Site URL, if one exists for the project. I will post as a full answer once I've cracked the 'active' status part of my question. – andyb Nov 23 '16 at 23:56

1 Answers1

0

I found this, that uses the last modified date to determine if it is active.

#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() 
}
Randy Schuman
  • 357
  • 1
  • 9
  • Thanks for the suggestion. It might be a good enough approximation for my purposes if I pick the right cut-off date. I think I'll let the question stand for a little longer though in the hope that there's a way of getting the actual Project Status via PSI. – andyb Aug 23 '16 at 03:09