Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum [Type] for a ProjectWise Folder
    • Sign In

    • State Not Answered
    • Replies 5 replies
    • Subscribers 67 subscribers
    • Views 502 views
    • Users 0 members are here

    [Type] for a ProjectWise Folder

    Robert Biggar
    Offline Robert Biggar over 1 year ago

    I am passing a ProjectWise folder into a function for processing created with:

    $PWfolder = get-pwfolders -FolderID $TfolderID -JustOne 

    what do I use for the Type in the Parameters in my function?

    ==================================================

    [CmdletBinding()]
    param
    (
    [Parameter(Mandatory=$true)]
    [???]$PWFolder

    )

    ====================================================

    I tried "ProjectWiseFolder"...but that was not correct...didn't work, anyway.

    maybe I didn't  specify that type correctly...or give it the right location to find that type??

    "Object" works...

    ===================================================

    [CmdletBinding()]
    param
    (
    [Parameter(Mandatory=$true)]
    [Object]$PWFolder

    )

    ===================================================

    but that seems a little Generic...

    is that the only option, or is there a way to specify that this is a ProjectWise Folder.

    Advice??

    Thanks!

    Bob

    • Sign in to reply
    • Cancel
    • Matt Kovach
      0 Offline Matt Kovach Fri, Jul 22 2022 12:11 PM

      Hello Bob,

      Any chance that you can post more of your code, so that we can see what you are doing with the $PWfolder object as well as how it is being created (i.e. the definition of $TfolderID)?

      Also, you have the pwps_dab PowerShell Module installed, correct?

      ProjectWise Explorer CONNECT Edition, Version 10.00.03.453

      ProjectWise Drive, Version 2022.1.328

      OpenRoads Designer CONNECT Edition, Version 10.09.00.91

      OpenRoads Designer CE 202 Release 2, Version 10.10.21.4

      Power GEOPAK V8i (SELECTseries 10), Version 08.11.09.918

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Robert Biggar
      0 Offline Robert Biggar Fri, Jul 22 2022 2:37 PM in reply to Matt Kovach

      sure.

      here is the function:

      ===================================================

      Function Break-Inheritance
      {
       [CmdletBinding()]
       param
       (
       [Parameter(Mandatory=$true)]
       [Object]$PWFolder                         #??? IS "Object" THE BEST TYPE TO BE USING?

       )


      $Fname = $PWfolder.name

      write-Host "Processing Folder... $Fname"

       ## TEMPORARY USER SETUP
       $MemberType = "u"
       $MemberName_1 = 'Spongebob'  #Temporary User
       $MemberAccess = 'r'
       $MemberAccessString_1 = '--CDrw-RW--'

       #ADD TEMP USER TO FOLDER (FORCING A CONVERT TO LOCAL FOR ACLs)

       $return = Update-PWFolderSecurity -InputFolder $PWfolder -MemberType u -FolderSecurity -DocumentSecurity -IncludeInheritance -  MemberAccess $MemberAccess -MemberName $MemberName_1 #-Verbose
       if ($return -eq $true)
         {
            write-Host "Security converted to local on ... $Fname"

            write-Host "Cleanup..."

            ## REMOVE TEMP USER - (BUG? ALWAYS RETURNS 50000 ERROR EVEN THOUGH USER IS REMOVED)
            Remove-PWFolderSecurity -InputFolder $PWfolder -MemberType $MemberType -MemberName $MemberName_1 -FolderSecurity -      DocumentSecurity

            write-Host "Successful on ... $Fname"

         }
      else
         {
            write-Host "Security unchanged on ... $Fname"
         }

      }

      ===================================================

      It is being called this way:

      ===================================================

      #Dialog to get folder
      $vault = Show-PWFolderBrowserDialog 
      if ($vault.Name.Length -eq 0)
      {
      cls
      Write-Host "Bye."
      exit
      }

      # EXTRACT "SELECTED FOLDER" INFO
      #-------------------------------------
      $TfolderID = $vault.ProjectID
      $Tvname = $vault.name
      $TDescription = $vault.Description
      $TargetPath = $vault.FullPath
      $TDepth = $vault.FolderDepth
      $Tcode = $vault.Code
      $TStorageArea = $vault.Storage
      $Tenv = $vault.Environment
      $IsRichProject = $vault.IsRichProject
      $IsParent = $vault.IsParent
      $ParentID = $vault.ParentID
      $TStorageAreaID = $vault.StorageID
      $TGUID = $vault.ProjectGUIDString
      $TURN = $vault.ProjectURN
      $TCreator = $vault.FolderCreator
      $TOwner = $vault.FolderOwnerName
      $TUpdater = $vault.FolderUpdaterName

      # CALL FUNCTION
      Break-Inheritance $vault

      ===================================================

      It works when I use "Object" as the Type...???

      It just seems like it is not quite right, and I am missing where to find the exact type I need.

      Thanks

      Bob

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Robert Biggar
      0 Offline Robert Biggar Fri, Jul 22 2022 2:47 PM in reply to Robert Biggar

      Powershell Version:

      Major Minor Build Revision
      ----- ----- ----- --------
      5 1 19041 1682
      ...
      ProjectWise Version:
      10.00.03.299
      ...
      PWPS DAB Version:
      2 1 8 0

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Robert McMillan
      0 Offline Robert McMillan Sun, Jul 24 2022 6:44 PM

      You can inspect the input types for other cmdlets from the Command Add-on in PowerShell ISE. In this case it's a [PWPS_DAB.CommonTypes+ProjectWiseFolder]

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Robert Biggar
      0 Offline Robert Biggar Mon, Jul 25 2022 7:18 AM in reply to Robert McMillan

      AH! It's always "right there" where you never thought to look...or just didn't pay attention.

      many thanks!!

      ...I wonder how many times I saw that...and just didn't read it??

      Just tested it...that was it.

      =====================================================

      [CmdletBinding()]
      param
      (
      [Parameter(Mandatory=$true)]
      [PWPS_DAB.CommonTypes+ProjectWiseFolder]$PWFolder

      )

      ======================================================

      Thank You!!

      Bob

      • 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