Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Updating Storage Areas with "Get-PWStorageAreaList" and "Update-PWStorage"
    • Sign In

    • State Not Answered
    • Replies 1 reply
    • Subscribers 67 subscribers
    • Views 886 views
    • Users 0 members are here
    • Storage Area
    • attribute

    Updating Storage Areas with "Get-PWStorageAreaList" and "Update-PWStorage"

    Robert Biggar
    Offline Robert Biggar over 4 years ago

    Hello:

    I am trying to update my Storage areas "Host"

    The cmdlet "Update-PWStorage" instructs to read in the information about the Storage area:

    age

    PS C:\PS> $storage = Get-PWStorageAreaList -Storageareanames "Storage Area"

    PS C:\PS> $storage

    Name        : Storage area
    ID          : 1
    StorageID   : 1
    Description : Storage area
    Host        : hcv591pwistaa01.ngds.state.mi.us
    Path        : d:/PWDataStorage/Storage AreaSA
    Protocol    : TCPIP

    Area"

    You are then supposed to change the parameters:

    PS C:\PS> $storage.Host = "hcv591pwispaa01.ngds.state.mi.us"

    . (and then "Update the Storage area")

    The Trouble is, every time I try to change any of the parameters, I get a "READ Only" Error:

    'Host' is a ReadOnly property.
    At line:1 char:1
    + $storage.Host = "hcv591pwispaa01.ngds.state.mi.us"
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : PropertyAssignmentException

    Wrong procedure?...

    or is there another way?

    Thanks

    Bob

    • Sign in to reply
    • Cancel
    Parents
    • Kevin van Haaren
      0 Offline Kevin van Haaren Wed, Dec 19 2018 2:33 PM

      Bentley has the properties in the object returned as read-only. You can tell because:

      > $storage | get-member
      
      
         TypeName: Bentley.ProjectWise.PowerShell.Common.Storage
      
      Name        MemberType Definition
      ----        ---------- ----------
      Equals      Method     bool Equals(System.Object obj)
      GetHashCode Method     int GetHashCode()
      GetType     Method     type GetType()
      ToString    Method     string ToString()
      Description Property   string Description {get;}
      Host        Property   string Host {get;}
      ID          Property   int ID {get;}
      Name        Property   string Name {get;}
      Path        Property   string Path {get;}
      Protocol    Property   string Protocol {get;}
      StorageID   Property   int StorageID {get;}
      

      all the properties are listed as {get;} if you could change them they would be listed as {get;set;}

      Not sure it'll work but you can try making your own object with the same properties and feed that back into Update-PWStorage:

      $new_storage = [pscustomobject]@{
          ID=$storage.ID
          Name=$storage.Name
          Description=$storage.Description
          Host=$storage.Host
          Path=$storage.Path
          Protocol=$storage.Protocol
          StorageID=$storage.StorageID
      }
      
      # change values for update
      $new_storage.host = 'new-value'
      
      

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Reply
    • Kevin van Haaren
      0 Offline Kevin van Haaren Wed, Dec 19 2018 2:33 PM

      Bentley has the properties in the object returned as read-only. You can tell because:

      > $storage | get-member
      
      
         TypeName: Bentley.ProjectWise.PowerShell.Common.Storage
      
      Name        MemberType Definition
      ----        ---------- ----------
      Equals      Method     bool Equals(System.Object obj)
      GetHashCode Method     int GetHashCode()
      GetType     Method     type GetType()
      ToString    Method     string ToString()
      Description Property   string Description {get;}
      Host        Property   string Host {get;}
      ID          Property   int ID {get;}
      Name        Property   string Name {get;}
      Path        Property   string Path {get;}
      Protocol    Property   string Protocol {get;}
      StorageID   Property   int StorageID {get;}
      

      all the properties are listed as {get;} if you could change them they would be listed as {get;set;}

      Not sure it'll work but you can try making your own object with the same properties and feed that back into Update-PWStorage:

      $new_storage = [pscustomobject]@{
          ID=$storage.ID
          Name=$storage.Name
          Description=$storage.Description
          Host=$storage.Host
          Path=$storage.Path
          Protocol=$storage.Protocol
          StorageID=$storage.StorageID
      }
      
      # change values for update
      $new_storage.host = 'new-value'
      
      

       

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    Children
    No Data

    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