Scripts/AddConnectedProjects.ps1
#Get all the rich projects in this tree $rps = Get-PWRichProjects -FolderPath "PWPS Connected Project Test 6\Projects 2" #foreach rich project, create a Connected Project foreach ($rp in $rps) { write-host $rp.ProjectID, $rp.ProjectProperties["PROJECT_Project_Name"], $rp.ProjectProperties["PROJECT_Location"], $rp.ProjectProperties["PROJECT_Project_Number"] Add-PWConnectedProject -InputFolder $rp -ConnectedProjectName $rp.ProjectProperties["PROJECT_Project_Name"] -ConnectedProjectNumber $rp.ProjectProperties["PROJECT_Project_Number"] -Location $rp.ProjectProperties["PROJECT_Location"] -MakeUnique } #will add the users with email who have logged in within the last year to the connected project identified by that path Get-PWUserByLastLogin -DaysAgo 365 -Since | Add-PWUsersToConnectedProject -FolderPath "PWPS Connected Project Test 6\Projects 2\Project A" #define folder variables $projectname = "Abbey Road Project01" $folderpath = "Rich Connected Projects\" + $projectname $targetFolder = $folderpath + "\PDFs" $sourceFolder = "Digital Signatures" #create rich project and add Connected Project $connectedProjectId = New-PWRichProject -NewFolderPath $folderpath -TemplateName "General" -StorageArea Storage -ProjectType "General" | Add-PWConnectedProject -Location "Durham, NC, USA" -AssetType "Building" -ConnectedProjectName $projectName -MakeUnique -Verbose #get matching users from ProjectWise and add them to the Connected Project $users = Get-PWUsersByMatch -Email "*eagle.bentley.com","*bentley.com" -Verbose Add-PWUsersToConnectedProject -InputUsers $users -FolderPath $folderpath # copy documents from source folder to a target folder and keep a list of the copied documents in a variable $copiedDocuments = Get-PWDocumentsBySearch -FolderPath $sourceFolder -FileName "%.pdf" | Copy-PWDocumentsToFolder -TargetFolderPath $targetFolder # set up variables for transmittal creation $transmittalName = "Transmittal for " + $projectname $transmittalComment = "Comment for " + $projectname $transmittalClassification = "Classification for " + $projectname # pass list of copied documents to create a transmittal New-PWDMTransmittal -InputDocument $copiedDocuments -ConnectedProjectId $connectedProjectId -TransmittalName $transmittalName -TransmittalComment $transmittalComment -Classification $transmittalComment -SendToEmails "dave.brumbaugh@eagle.bentley.com","dave.brumbaugh@bentley.com" -Verbose |