I want to copy a template folder and create 30 projects and rename the projects and the cad files present inside the project from a list of project names in an excel spreadsheet. Can anyone help with a PowerShell command?
What have you tried so far?
You should be able to do much of what you want with New-PWRichProjectsFromSpreadsheet. Take a look at the help for how to create the spreadsheet (formatting), as well as the examples.
You might want to look at the other Cmdlets that work with "Rich Projects":
If you actually mean that you want to copy a template for each project, and then rename it, and some of the files in the template, that will take a bit of scripting, and that would means that you have to determine the steps needed to get the name of each project, create the project from a template using that name. Then search for the documents that you want to rename in that project's folder structure, etc.
Dan WilliamsSolution ConsultantBentley Systems, IncorporatedPortland, OR, USA (Pacific Time UTC-08:00)
Thank you, Dan. I want to use the same template for all 30 projects and I need to rename the 30 new project folders and the 2 documents inside those project folder.
I have the new folder names and document names stored in a spreadsheet in my local drive or I can store it inside the ProjectWise. Can you please provide some insights?
It all depends upon the specifics of your data, i.e. how your data is stored in your spreadsheet.
Take a look at the help for New-PWRichProjectFromTemplate. "EXAMPLE 2" might work for your needs. You can loop through your list of folder names passing the full folder path to -NewFolderPathName and providing the other parameters as needed.
As for renaming the two documents inside of the new rich project, you can do that inside your loop after you create the new rich project with Update-PWDocumentProperties.
Thank you for helping, my knowledge in PowerShell is very limited, I am trying to learn PowerShell.
I tried copying a template folder with the "New-PWRichProjectFromTemplate" cmdlet and I am getting the following error (Please see below in bold).
Instead of manually inputting the NewProjectName, I need to redirect that to the spreadsheet, how do I do that? My spreadsheet has two columns. Column 1 - New project name, Coloum 2 - New document name.
PS C:\Users> New-PWRichProjectFromTemplatecmdlet New-PWRichProjectFromTemplate at command pipeline position 1Supply values for the following parameters:InputFolder: get-pwfolders -Folderpath 'Construction Services'NewProjectName: testTemplateName: 'Linear Project'StorageArea: PW SandboxNew-PWRichProjectFromTemplate : Invalid ProjectWise folder object provided.At line:1 char:1+ New-PWRichProjectFromTemplate+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [New-PWRichProjectFromTemplate], Exception + FullyQualifiedErrorId : Invalid ProjectWise folder object provided.,PWPS_DAB.NewPWRichProjectFromTemplate
Here's an example based upon an Excel spreadsheet that looks like this:
Here's what the Template looks like:
The file in Sub01 is named 'test.txt' and in Sub02 it is named 'test.xlsx'.
And here's the results of the sample script:
And here is the sample script:
# sign into your datasource...
# read your spreadsheet into a datatable
# spreadsheet column names
# TargetPath ProjName Template Storage Doc01Path Doc01 Doc01Renamed Doc02Path Doc02 Doc02Renamed
$dt = Get-TablesFromXLSXWorkbook -InputFileName 'C:\Scripts\NewProjectInfo.xlsx'
# loop through the datatable rows and process each one
foreach($row in $dt.rows)
# create project
New-PWRichProjectFromTemplate -newFolderPathName $row.TargetPath -NewProjectName $row.ProjName -TemplateName $row.Template -StorageArea $row.Storage -verbose
# rename doc01
$doc01 = Get-PWDocumentsBySearch -FolderPath $row.Doc01Path -FileName $row.Doc01 -Verbose
$doc01.Name = $row.Doc01Renamed
$doc01.FileName = $row.Doc01Renamed
Update-PWDocumentProperties -InputDocument $doc01 -Verbose
# rename doc02
$doc02 = Get-PWDocumentsBySearch -FolderPath $row.Doc02Path -FileName $row.Doc02 -Verbose
$doc02.Name = $row.Doc02Renamed
$doc02.FileName = $row.Doc02Renamed
Update-PWDocumentProperties -InputDocument $doc02 -Verbose
# sign out
As it really depends upon how you structure your input data, as well how you manipulate that data in your script, there are many ways to create a script to do what you have described. Also, this sample has no error trapping, etc. but at least you have something to start your own script with.