Create a #ProjectServer #PS2010 #PS2013 project from a template and update the EPT #SP2013 #SP2010 #PowerShell
I am a Project Server and SharePoint consultant but my main focus currently is around Project Server.
I have been working with Project Server for nearly five years since 2007 for a Microsoft Gold Certified Partner in the UK, I have also been awared with the Microsoft Community Contributor Award 2011. I am also a certified Prince2 Practitioner. This article has been cross posted from pwmather.wordpress.com (original article) |
I have been meaning to publish this PowerShell script for a few months but finally got around to it today. The PowerShell script creates a project from a template then updates the Enterprise Project Type (EPT). I did write a post over a year ago on how to create a project using PowerShell but this didn’t update the EPT:
The issue is that even if your Project Plan Template is associated to an EPT in Project Server, the project created from the CreateProjectFromTemplate method is associated to the default EPT regardless. This script will prompt for the project name, the project plan template name and the EPT name. It will create the project then update the project to associate it to the desired EPT. The script can be downloaded from the script gallery below:
http://gallery.technet.microsoft.com/scriptcenter/Create-Server-2010-2013-19bd3cc7
Once downloaded, the script will need to be updated with the correct PWA URL, the lines that need updating are 9 and 23. These can bee seen below:
Update the http://vm753/pwa part of the URL for your PWA URL.
A walkthrough using the script is below.
Open Windows PowerShell and navigate to the PowerShell file, in this example it is on the desktop:
Press Enter and complete the details:
The new Project will be called “CPS Test Project by Paul Mather”, it will use the “PMTemp1” template and then associate the new project to the “PM TEST” EPT.
The project is created as you can see in the Project Center:
It is also associated to the specified EPT:
The default EPT on this PWA instance is “Enterprise Project”:
When using the CreateProjectFromTemplate method only, this new project would have been associated to the Enterprise Project EPT as this is the default EPT.
This is just an example of what can be done, many improvements could be made, certainly around error handling but it provides a working example for you to build on.
Good Script. I have used this in per SP1 versions of Project Server 2013 however I just tried (Same script as before different environment with PS 2013 SP1 and the Dec 2015 CU and I am getting and interesting error. (I have looked at the “” copied to notepad” and even plugged the GUID of the template (pulled from SQL) in. and I still get this error:
Exception calling “CreateProjectFromTemplate” with “2” argument(s): “ProjectServerError(s) LastError=rsResourceCannotAddLocalWithSameNameAsEnterprise
Instructions: Pass this into PSClientError constructor to access all error information”
At line:13 char:1
+ $NewProjGUID = $svcPSProjProxy.CreateProjectFromTemplate(“7CA68F3B-71A3-E511-B44 …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : SoapException
Cannot convert argument “projectUid”, with value: “”, for “QueuePublish” to type “System.Guid”: “Cannot convert value “” to type “System.Guid”. Error:
“Unrecognized Guid format.””
At line:17 char:1
+ $svcPSProjProxy.QueuePublish(“$G”, “$NewProjGUID”, “true”,””)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodArgumentConversionInvalidCastArgument