Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Add-PWDocumentsWithCode
    • Sign In

    • State Not Answered
    • Replies 1 reply
    • Subscribers 64 subscribers
    • Views 565 views
    • Users 0 members are here

    Add-PWDocumentsWithCode

    Peter Willmen
    Offline Peter Willmen over 3 years ago

    I need to create  a new document with a document Code and a file with a matching name (e.g. Doc "ABC-123-0001" Filename "ABC-123-0001.DGN") and any help would be appreciated.

    The cmdlet help states:-

        "# Create 5 abstract documents using document code populated with the passed default attribute values and then attach a dummy file to each with the appropriate name
        Get-PWFolders -FolderPath 'Replicated\Project 01' | Add-PWDocumentsWithCode -Attributes @{ ProjectNumber = 'BSI400'; AreaShort = 'RW'; DocumentTypeShort = '2DM'; LevelShort = 'NA' } -NumberOfDocuments 5 | Update-PWDocumentFile -NewFile 'C:\temp\dummy.txt' -UseDocumentName"

    This works fine up to the 'Update-PWDocumentFile' part as the parameters above do not match the parameters in the cmdlet:-

        Update-PWDocumentFile [-InputDocuments] <ProjectWiseDocument[]> [-NewFilePathName] <string> [[-NewFileName] <string>] [-RemoveFile <SwitchParameter>] [<CommonParameters>]
        Update-PWDocumentFile [-InputDocuments] <ProjectWiseDocument[]> [-NewFilePathName] <string> [-KeepExistingFileName <SwitchParameter>] [-RemoveFile <SwitchParameter>] [<CommonParameters>]
    The parameters in Update-PWDocumentFile only seem to work where a file already exists [-KeepExistingFileName] or the file name is specified [NewFileName], neither of which are suitable when using a document code.as the name is auto generated
    Hope that makes sense!

    • Sign in to reply
    • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Thu, Feb 13 2020 8:20 AM

      You are correct. It should be -NewFilePathName.   I will update the help information for the Update-PWDocumentFile cmdlet.

      In the example, we are taking advantage of Piping. We generate the new abstract documents and pass the new document objects via the pipeline to the Update-PWDocumentFile cmdlet. It passes the document objects into the -InputDocuments parameter.   Hope this helps.

      • 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