Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum PowerShell Create new ProjectWise folder from template and Excell file
    • Sign In

    • State Not Answered
    • Replies 28 replies
    • Subscribers 66 subscribers
    • Views 727 views
    • Users 0 members are here
    • powershell
    • powershellscripting
    • powerwisescripting.blog

    PowerShell Create new ProjectWise folder from template and Excell file

    JosephCyriac
    Offline JosephCyriac 28 days ago

    New-PWLogin
    
    $outfile = Get-TablesFromXLSXWorkbook -InputFileName 'C:\Users\joseph\Desktop\OutFile.xlsx '
    
    foreach($row in $outfile.rows)	
    {
        New-PWRichProjectFromTemplate -newFolderPathName $row.FolderPath -NewProjectName $row.FolderName -Template Name $row.TemplateFolder -Storage Area $row.StorageArea -verbose
    } 
    Undo-PWLogin  

    I am using the above code to create projectwise folders copying the template folder which is stored in the projectwise. But after executing one line from the Excel sheet the PowerShell quit unexpectedly. Can you please provide a solution? See below for the screenshot of the Excel file format.

    • Sign in to reply
    • Cancel

    Top Replies

    • Bill Graefe
      Offline Bill Graefe Thu, Sep 14 2023 5:12 PM in reply to JosephCyriac +1
      Did you run it in the ISE with a breakpoint then inspect the variables as you stepped through the loop? Putting $outfile | Out-GridView Before the loop with breakpoint could also help.
    • Adrian Crowfoot
      Offline Adrian Crowfoot Fri, Sep 15 2023 10:03 AM in reply to JosephCyriac +1
      JosephCyriac - I have two observations: 1. Your values have spaces. You might want to validate that your splatted hashtable values match the values in the rows. Also, make sure to remove any leading or…
    Parents
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Sep 14 2023 3:38 PM

      Probably should have asked this initially, which version of ProjectWise are you using?  Which version of the pwps_dab module are you using?  Ensure the account you are using to run the script has the appropriate permissions for creating, updating Work Areas and folders.  Have you tried turning off "Use Access Control" for the user account?

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • JosephCyriac
      0 Offline JosephCyriac Thu, Sep 14 2023 3:57 PM in reply to Brian Flaherty

      The version I am using is ProjectWise Explorer Version 10.00.02.265 - Commercial Release

      pwps_dab Version 23.3.0.0

      I am in the admin list and I have permission to create or update work areas. If i don't have access it should have prevented creating the first work area itself right? 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Sep 14 2023 4:58 PM in reply to JosephCyriac

      That is correct. But you may not be able to update properties, etc.   Just covering all basis.  Without seeing what is occurring, I am not sure how to resolve this for you. The code as you have it should work.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Reply
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Sep 14 2023 4:58 PM in reply to JosephCyriac

      That is correct. But you may not be able to update properties, etc.   Just covering all basis.  Without seeing what is occurring, I am not sure how to resolve this for you. The code as you have it should work.

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Children
    • Kevin van Haaren
      0 Offline Kevin van Haaren Thu, Sep 14 2023 6:27 PM in reply to Brian Flaherty

      I'm not seeing a pwps_dab 23.3.0.00 on PowerShell Gallery

      With version 23.2.6.0 I found when using -NewFolderPathName the path specified has to be the entire path to the work area, not the path to folder above the work area. You still need to specify the -NewProjectName but the path has to be the full path.

      I changed the splat to this and it started working for me:

      $Splat_New = @{
      	NewFolderPathName = Join-Path $row.FolderPath $row.FolderName
      	NewProjectName    = $row.FolderName
      	TemplateName      = $row.TemplateFolder
      	StorageArea       = $row.StorageArea
      }
      

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • JosephCyriac
      0 Offline JosephCyriac Fri, Sep 15 2023 8:43 AM in reply to Kevin van Haaren

      I tried this today morning, but this is not working either. Same issue. Maybe there is some setting in my ProjectWise I need to change, can someone direct me?

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • JosephCyriac
      0 Offline JosephCyriac Fri, Sep 15 2023 9:10 AM in reply to Brian Flaherty

      Or is there any other method I can use to perform this other than PowerShell?

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Adrian Crowfoot
      0 Offline Adrian Crowfoot Fri, Sep 15 2023 10:03 AM in reply to JosephCyriac

      JosephCyriac - I have two observations:

      1. Your values have spaces. You might want to validate that your splatted hashtable values match the values in the rows. Also, make sure to remove any leading or trailing spaces by using the Trim method.

      2. Make sure to add the '\' character between the FolderPath and FolderName when joining the two values. Also, you may need to wrap your $row values with a '$()' if you are getting undesired results.

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • JosephCyriac
      0 Offline JosephCyriac Fri, Sep 15 2023 10:25 AM in reply to Adrian Crowfoot

      Hi Adrian , i just tried that too , not working 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel

    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies