Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum New-PWDocumentVersion Error/Exception Handling
    • Sign In

    • State Verified Answer
    • Replies 6 replies
    • Subscribers 66 subscribers
    • Views 2164 views
    • Users 0 members are here
    • powershell
    • ProjectWise
    • Exception Handling

    New-PWDocumentVersion Error/Exception Handling

    Jim Turner
    Jim Turner over 5 years ago

    I am using New-PWDocumentVersion cmdlet as part of a script to synchronize DGN files on a server drive with the respective holdings on ProjectWise.

    To deal with problems and exceptions in my script I have the following set:

    $ErrorActionPreference = "Stop"
    $WarningPreference = "Inquire"

    The basic process involves creating a new version and uploading the PW document if the server file is more up-to-date than the PW file.  I create new versions like such and then update the file:

    Get-PWDocumentsBySearch -FolderPath $pwfolder -FileName $theFile  | New-PWDocumentVersion -VersionString $verString | Out-Null

    Get-PWDocumentsBySearch -FolderPath $pwfolder -FileName $theFile  | Update-PWDocumentFile -NewFilePathName $newfile | Out-Null 

    For an unexplained reason the New-PWDocumentVersion cmdlet is failing, with the following text written to screen:

    Error changing document '\path\xxx.dgn' to new version

    The reason for the error is not clear and I am so far unable to recreate it consistently.  Most distressingly however, because the error is not raised as a normal Powershell exception, the script blithely continues and actually overwrites the document of the previous version.

    Please can the cmdlet be updated to raise exceptions correctly?  Actually I've also noted this on other cmdlets too, including Update-PWDocumentAttributes, therefore this request can be opened up to all cmdlets.

    • Sign in to reply
    • Cancel

    Top Replies

    • Brian Flaherty
      Offline Brian Flaherty Mon, Nov 19 2018 8:24 AM +1 verified
      The New-PWDocumentVersion cmdlet has been updated to return a more informative message if/when and error occurs. Look for the update in a future release of the PWPS_DAB module.
    • Brian Flaherty
      +1 Offline Brian Flaherty Mon, Nov 19 2018 8:24 AM

      The New-PWDocumentVersion cmdlet has been updated to return a more informative message if/when and error occurs. Look for the update in a future release of the PWPS_DAB module.  

      Answer Verified By: Jim Turner 

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject 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