Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
ProjectWise
  • Product Communities
ProjectWise
ProjectWise PowerShell Extensions Forum Export-PWProjectAccessControl crash on datasource with globally defined workflow rules - Feature request?
    • Sign In

    • State Suggested Answer
    • Replies 4 replies
    • Answers 1 answer
    • Subscribers 64 subscribers
    • Views 1164 views
    • Users 0 members are here
    • powershell
    • Export-PWProjectAccessControl
    • ProjectWise

    Export-PWProjectAccessControl crash on datasource with globally defined workflow rules - Feature request?

    Chris Spencer
    Offline Chris Spencer over 3 years ago

    pwps_dab 1.18.1.0

    Running Export-PWProjectAccessControl on a datasource with workflow security assigned at datasource level on a Folder with 534 sub folders takes some time and eventually crashes with:

    Export-PWProjectAccessControl : StartIndex cannot be less than zero.
    Parameter name: startIndex
    At line:6 char:1
    + Export-PWProjectAccessControl @Splat -Verbose
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Export-PWProjectAccessControl], ArgumentOutOfRangeException
    + FullyQualifiedErrorId : System.ArgumentOutOfRangeException,PWPS_DAB.ExportPWProjectAccessControl

    Is there a way to strip out the reporting of workflow security which is derived from the global datasource setting reporting for each workflow security assigned to a folder at the cmdlet level rather than after running the cmdlet which is what I am doing now?. This lack of ability to filter is creating far to much output and eventually crashes.

    If no other way - Ideally I would like a switch in Export-PWProjectAccessControl to ignore workflow from the global datasource settings or anything that is not folder own permission related...i.e. -NoGlobalWorkflow or -OwnFolderPermissions or something of that nature.

    I have developed my own crude way of filtering this out. However on large folder trees I cannot get the raw data in order to filter due to the crash. This is how I am filtering by converting the excel output to CSV, , then importing as a datatable and selecting what I want before outputting to excel again so it can be used with the Import-PWProjectAccessControl cmdlet. This works on smaller selections, but not on my 534 sub folder selection due to the Export-PWProjectAccessControl crash. I am using 64 bit PowerShell...

    #####--- Login PW ---#####
    New-PWLogin

    #####--- Export permission info to Excel ---#####
    $Splat = @{
    InputFolder = 'Test Folder\perms'
    FolderLevel = 0
    ExportFilePathName = 'c:\temp\foldersecurity.xlsx'
    }
    Export-PWProjectAccessControl @Splat -Verbose

    #####--- Convert spreadsheet to CSV ---#####

    Function Convert-ExelToCSV ($excelFileName, $csvPathName) {
    write-host $excelFileName, $csvPathName
    $E = New-Object -ComObject Excel.Application
    $E.Visible = $false
    $E.DisplayAlerts = $false
    $wb = $E.Workbooks.Open($excelFileName)
    $ws = $wb.Worksheets.item(1)
    $ws.SaveAs($csvPathName, 6)
    $E.Quit()
    #Clean up Excel process as it didn't quit
    [System.GC]::Collect()
    [System.GC]::WaitForPendingFinalizers()
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($ws)
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($wb)
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($E)
    Remove-Variable -Name E
    }

    Convert-ExelToCSV -excelFileName 'c:\temp\foldersecurity.xlsx' -csvPathName "C:\temp\t.csv"

    #####--- Drop anything workflow or not 'none (folder own permissions)' related and reexport as t2.csv ---#####

    $csvrows = Import-Csv "C:\temp\t.csv"
    #$csvrows | ogv
    #Filter out anything other the folder own permissions
    $folderownperms = $csvrows | Where-Object { $_.InheritingFrom -eq 'none (folder own permissions)' }
    $folderownperms = $folderownperms | Where-Object { $_.Workflow -eq '' }
    #Save filtered as temp csv
    $folderownperms | Export-Csv "C:\temp\t2.csv" -Encoding UTF8 -NoTypeInformation

    #####--- Create / save t2.csv in excel as t3.xlsx for use in import ---#####
    $E = New-Object -ComObject excel.application
    $E.Visible = $false
    $E.DisplayAlerts = $false
    $wb = $E.Workbooks.Open("C:\temp\t2.csv")
    $ws = $wb.Worksheets.item(1)
    $E.ActiveWorkbook.SaveAs('c:\temp\t3.xlsx', 51)
    $E.Quit()
    #Clean up Excel process as it didn't quit
    [System.GC]::Collect()
    [System.GC]::WaitForPendingFinalizers()
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($wb)
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($ws)
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($E)
    Remove-Variable -Name E


    #####--- Import the permissions from our new t3.xlsx excel file ---#####
    Import-PWProjectAccessControl -InputFolder "Admin Area\Test\permtest" -ImportFilePathName 'c:\temp\t3.xlsx' -verbose

    #####--- Logout PW ---#####
    Undo-PWLogin

    #The offending real life situation sample Code (cmdlet) which results in failure:

    PS C:\Users\AdminCS> New-PWLogin
    True
    PS C:\Users\AdminCS> $Splat = @{
    InputFolder = 'Standard Documents & Drawings - TSPProjects\M&E (MEE)'
    FolderLevel = 0
    ExportFilePathName = 'c:\temp\foldersecurity.xlsx'
    }
    Export-PWProjectAccessControl @Splat -Verbose
    VERBOSE: Path section removed from FullPath: 'Standard Documents & Drawings - TSPProjects'.
    VERBOSE: ProjectName: 'M&E (MEE)'.
    VERBOSE: Found 534 folders

    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Standard Documents & Drawings - TSPProjects\M&E (MEE).
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    VERBOSE: Inheriting from folder Datasource Global Permissions.
    ....................

    ....... A very long wait and thousands of more lines to paste into here before the crash............
    ....
    Export-PWProjectAccessControl : StartIndex cannot be less than zero.
    Parameter name: startIndex
    At line:6 char:1
    + Export-PWProjectAccessControl @Splat -Verbose
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Export-PWProjectAccessControl], ArgumentOutOfRangeException
    + FullyQualifiedErrorId : System.ArgumentOutOfRangeException,PWPS_DAB.ExportPWProjectAccessControl

    Anyone else getting this or have a workaround?

    Thanks

    Chris

    • Sign in to reply
    • Cancel

    Top Replies

    • Robert McMillan
      Offline Robert McMillan Tue, Feb 25 2020 6:57 PM +1
      I haven't tried this from PowerShell but in ProjectWise Explorer if you remove unused Workflows from the Work Area's resources the access control export doesn't include rows for those workflows on those…
    • Brian Flaherty
      Offline Brian Flaherty Fri, Feb 28 2020 3:13 PM +1 suggested
      This issue has been resolved in version 1.19.0.0 of the PWPS_DAB module.
    • Robert McMillan
      0 Offline Robert McMillan Tue, Feb 25 2020 6:57 PM

      I haven't tried this from PowerShell but in ProjectWise Explorer if you remove unused Workflows from the Work Area's resources the access control export doesn't include rows for those workflows on those folders/subfolders.

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Chris Spencer
      0 Offline Chris Spencer Wed, Feb 26 2020 10:26 AM in reply to Robert McMillan

      Hi Robert - The project level has many workflows defined for many sub folders with disciplines. Therefore this solution would not be practical on this occasion. A fix to the module or my request to stop the globally defined workflow permissions being exported and an option to report on folder own permissions only is required. I hope the development team can see the need for this requirement as I am sure it could possibly affect many with projects that contain multiple disciplines with workflow / groups controlling them defined on a datasource level. 

      • Cancel
      • Vote Up 0 Vote Down
      • Sign in to reply
      • Verify Answer
      • Cancel
    • Brian Flaherty
      0 Offline Brian Flaherty Fri, Feb 28 2020 3:13 PM

      This issue has been resolved in version 1.19.0.0 of the PWPS_DAB module.

      • Cancel
      • Vote Up +1 Vote Down
      • Sign in to reply
      • Verify Answer
      • Reject Answer
      • Cancel
    • Chris Spencer
      0 Offline Chris Spencer Wed, Mar 11 2020 5:08 AM in reply to Brian Flaherty

      Thanks for the fix Brian. It now runs.

      However it is slow and ideally I would like a switch to remove clutter.

      i.e. only get 'none (folder own permissions)' would be a nice feature to see where the folder and document permissions are set would be great if this would be possible?

      Timings for Rich Project with 534 folders:

      10 March 2020 11:42:25
      VERBOSE: Path section removed from FullPath: 'Standard Documents & Drawings - TSPProjects'.
      VERBOSE: ProjectName: 'M&E (MEE)'.
      VERBOSE: Found 534 folders
      VERBOSE: 'Documents' is inheriting access control
      VERBOSE: - InheritingFrom: 'Standard Documents & Drawings - TSPProjects\M&E (MEE)'
      VERBOSE: - Type: 'Project'
      VERBOSE: - MemberName: 'administrator'
      VERBOSE: - AccessMask: 'FPCDrw-----'

      .....

      ....

      ....

      ....

      VERBOSE: Successfully exported access control data to file 'c:\temp\foldersecurity.xlsx'
      True
      10 March 2020 12:44:15

      Total time 

      1 hour, 1 minute and 50 seconds. Output is a spreadsheet with 1075 rows.

      Thanks

      Chris

      • 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