Access #ProjectOnline #Project sites using #PowerShell and #SharePoint CSOM #Office365July 8, 2016 at 8:26 pm | Posted in Add-on, Administration, Configuration, Customisation, Functionality, Information, PowerShell | Leave a comment
Tags: Office365, PowerShell, PPM, Project Online, Project Server 2013, Project Server 2016
This PowerShell script will use the Project Reporting OData API to get a list of all the Project Sites in the PWA Site Collection linked to a project. It will then access each of those project sites to enable you to easily update / review the site if needed. This example just lists all of the list titles for each site but can be used as a starting script for modifying a particular list or adding a new list on all project sites etc. This could be used to help rollout changes to existing Project Sites, the code here will help you get connected and access each Project Site object using CSOM. You could even use this example to get the project site URLs then use the approach I blogged about the other month with the PnP PowerShell to month the sites. The example is for Project Online but could easily be updated for Project Server 2013 / 2016.
The user running the script will need to update the source PWA instance URL, username and password. The account will need access to the OData API in PWA and access to all of the project sites.
This script example can be downloaded here: https://gallery.technet.microsoft.com/Access-all-Online-Projects-568c7c59
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.
The good thing about using the OData API to return the list of Project Site URLs is that if you have certain sites for each Enterprise Project Type you could easily filter the OData query to only return the project site URLs for the correct Enterprise Project Type.
Once 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), firstly this example will give you a count of project sites:
Then for each of those sites it will list all of the SharePoint lists on each site:
As mentioned, this just lists all of the lists so probably isn’t that useful unless you wanted to check each Project Site had the correct lists. The script could be modified to update those project sites or lists fairly easily depending on what the changes were. All I would say is that if you are looking to update / make changes to the project sites, fully test your modified script on a non-production PWA instance first as you could cause a lot of damage if you weren’t careful!
The script is provided "As is" with no warranties etc.