#ProjectOnline data capture / snapshot capability with #PowerShell #SharePoint #Office365 #PPM #BIAugust 26, 2016 at 11:03 am | Posted in Add-on, Administration, Configuration, Customisation, Functionality, Information, PowerShell, Reporting | 1 Comment
Tags: Office365, PowerShell, PPM, Project 2013, Project 2016, Project Online, SharePoint Online
This blog post will show an option to capture Microsoft’s PPM Project Online data into a SharePoint list on a schedule to enable time driven data capture for snapshot / trend reporting capability. This example makes use of a PowerShell script I created to get the data and write this to a SharePoint list. The PowerShell script will use the Project Reporting OData API to get all of the specified project data in the PWA Site Collection then create a list item on the specified SharePoint list. The user setting up the script will need to update the source PWA instance URL, username, password and list name. The account specified will need access to the OData API in PWA and contribute access to the target SharePoint list. The SharePoint list will also need to be created beforehand with the required columns. The OData query will need to be updated to include the correct project level fields required and the part of the script that creates the list items will need to be updated too. This is covered below.
This script example can be downloaded here: https://gallery.technet.microsoft.com/Online-Snapshot-example-0437b680
To get the script to work you will need to reference the DLL as seen in the image below:
This can be installed from the SharePoint Online Client components / management shell. I used the dll from the SharePoint Online Management Shell in this example.
Please note, this has only been tested in PowerShell 3.0 and might not work in other versions. If you have any issues try this in PowerShell 3.0.
Firstly decide what project level fields you want to capture, this will determine the list column requirements. Then create the SharePoint list in the PWA site collection with the required columns, for this example I created a list called ProjectSnapShots with the columns below:
The SnapshotDate column was set to have today as the default value so that when the items are created the date is set automatically.
Update the Project OData query to include the correct fields that you want to capture, in this simple example I have included the following:
$url = $PWAInstanceURL + "/_api/ProjectData/Projects()?`$Filter=ProjectType ne 7&`$Select=ProjectId,ProjectName,ProjectPercentCompleted,ProjectHealth,ROI,RiskRating&`$orderby=ProjectName"
As you can see I have a list column for each project level field. The next part of the script that needs to be updated is the item creation:
This is where you map the project level fields to the correct SharePoint list columns based on the data you are capturing.
Also ensure the variables have been updated correctly, placeholder values seen below:
Save and run the PowerShell script (fully test on a non-production PWA site collection before Production) to ensure the data is captured correctly in the target SharePoint list. You could then set this up to run as a scheduled task on a local server or a scheduled WebJob in Azure to capture the data weekly or monthly etc. For details on a scheduled WebJob see: https://azure.microsoft.com/en-gb/documentation/articles/web-sites-create-web-jobs/
Once the script is run you will see the data in the SharePoint list, below I have run this 3 times:
You could then create a snapshot / trend report as required from the list data and even join to the live Project OData API if you capture the Project ID as I have in the example script / list.
A simple time driven data capture to enable snapshot / trending reports for Project Online. This script could easily be modified to capture the data into a SQL database, either on-prem or in Azure SQL if required. Also if this was to be run in production the script should be updated for error handling with try / catch blocks etc.
The script is provided "As is" with no warranties etc.