none
How to delete all Project Online resources without assignments RRS feed

  • Question

  • Due do a problem with the synchronisation between active directory and the Project Online resource center we have 9000+ resources in Project Online which are useless.

    I would like to delete in bulk all resources without assignments ? 

    Is this possible with Powershell for example?

    Thanks in advance for your help.

    Kind regards

    Ron Becker

    Thursday, August 16, 2018 5:50 AM

Answers

  • Hi Ron,

    Yes you could write a PowerShell script that deleted resources. You could use the delete method in the Enterprise Resource class: https://msdn.microsoft.com/en-us/office/project/api/enterpriseresource#DeleteObject__

    Add the dlls into your PowerShell script then you will be able to use CSOM or without the dlls you could use the REST API.

    Regarding only deleting resources without assignments, I think the delete method might throw an exception if the resource has assignments (test this out on a test resource first) but if it doesn't, you will need to query all the resources, then for all the resources query if they have an assignment to then get a data set of resource GUIDs where the resources have no assignments, then delete those.

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads

    Friday, August 17, 2018 7:16 AM
    Moderator

All replies

  • Hi Ron,

    Yes you could write a PowerShell script that deleted resources. You could use the delete method in the Enterprise Resource class: https://msdn.microsoft.com/en-us/office/project/api/enterpriseresource#DeleteObject__

    Add the dlls into your PowerShell script then you will be able to use CSOM or without the dlls you could use the REST API.

    Regarding only deleting resources without assignments, I think the delete method might throw an exception if the resource has assignments (test this out on a test resource first) but if it doesn't, you will need to query all the resources, then for all the resources query if they have an assignment to then get a data set of resource GUIDs where the resources have no assignments, then delete those.

    Paul


    Paul Mather | Twitter | http://pwmather.wordpress.com | CPS | MVP | Downloads

    Friday, August 17, 2018 7:16 AM
    Moderator
  • Hi Paul,

    We have similar requirement. We implemented CSOM script as you described but our code is taking 2-3 minutes to delete each resource. If I delete one or more resources usine PWA Settings -> Delete Enterprise Objects -> Resources and Users, it is quick. Below is the code I'm using to delete each Enterprise Resource in loop.                      

    ColActiveResources.GetByGuid(newGuid(resGUID)).DeleteObject();

    ColActiveResources.Update();                       

    projContext.ExecuteQuery();

    Please suggest how we can optimize our logic. Thanks in advance.

    Kiran

    Monday, February 4, 2019 12:15 AM
  • Hi Kiran,

    CSOM is geeting error to me.

    + ColActiveResources.GetByGuid(newGuid(

    Please provided complete script.

    Thanks & Regards,

    Venkata

    Monday, July 15, 2019 3:37 PM