I am trying to use the Import-PWDocuments cmdlet to create/update documents (pwps_dab 1.25.1.0).
I simply want to import all the content of a folder on my local drive to an existing folder in ProjectWise.
The first time, if the document does not exist, it should be created in PW. If it exists, if should be updated. No version is needed here, a simple overwrite will do.
Take this example:
FROM: C:\Temp\Samples\ImportFrom\
TO: pw:\\<server:datasource>\Documents\Test-Project\Samples\
After connecting to the datasource, the script looks like:
If the ProjectWiseFolder path specified exists then the Import-PWDocuments cmdlet will inherit that folders storage area as it creates any subfolders below that, however if it does not exist it is necessary to define the -DefaultStorage parameter as input to the cmdlet so ProjectWise knows which storage area to apply to the folders created. So in your example above either create the ProjectWise folder "Test-Project\Samples" before running your script or supply the -DefaultStorage parameter. You can check the available storage areas with Get-PWStorageAreaList
Hi Olivier Doucet
Did you found the solution for this, even I am getting the same error.. Since I am new to PW and powershell, unable to resolve it.
Hi,I ended up checking if the top folder path already exists in projectwise and create it if it doesn't.Only then I run Import-PWDocuments.I hope this helps
could you please share the command because the projectwise is already having the folder structure which I am trying to give in -ProjectWiseFolder
I am sorry but I cannot find the exact context and code for it. The code I used this for is now defunct.Did you try what Robert McMillan suggested?At some point I wrote the following function as I was experiencing some trouble with Create/Update docs in PW.Maybe it helps:
#Requires -Modules pwps_dab function CreateOrUpdate-PWDoc { [cmdletbinding()] param ( [Parameter( Mandatory = $true, ValueFromPipeline = $true)] [string]$InputFilePath , [Parameter(Mandatory = $true)] [Alias('TargetDirPath')] [string]$TargetFolderPath ) Process { $targetDocName = Split-Path -Path $InputFilePath -Leaf Write-Host "Searching for document $TargetFolderPath\$targetDocName." $docSearch = @{ FolderPath = $TargetFolderPath JustThisFolder = $true FileName = $targetDocName GetVersionsToo = $false Verbose = $false WarningAction = "Continue" # Remove quotes around "Continue" and you'll jump to next iteration /!\ } $docs = Get-PWDocumentsBySearchWithReturnColumns @docSearch $matchCount = $docs.Count if (0 -eq $matchCount) { # Create new New-PWDocument -FilePath $InputFilePath -FolderPath $TargetFolderPath -WarningAction Stop Write-Host "Created new document $TargetFolderPath\$targetDocName." return } if (1 -eq $matchCount) { # Update/overwrite existing $docs[0] | Update-PWDocumentFile -NewFilePathName $InputFilePath -WarningAction Stop Write-Host "Updated document $TargetFolderPath\$targetDocName." return } Write-Error "The search for $targetDocName yielded $matchCount matches..." } }