Be sure to check out my Scripting4Crypto initiative. It’s a fun way to get into using cryptocurrencies all while getting your PowerShell needs met.
With the latest release of the PWPS_DAB module (version 1.10.2.0), we have added two new cmdlets to hopefully make updating project access control easier. The new cmdlets work together. You’ll use the Export-PWProjectAccessControl cmdlet to export the desired access control to a datatable, SQLite database or an Excel workbook. Then use the Import-PWProjectAccessControl cmdlet to import the access control from the datatable, database or workbook to update the access control for a another specified project.
Before continuing I would recommend taking a look at the help information for each of the cmdlets to familiarize yourself with the functionality, parameters, etc.
- Export-PWProjectAccessControl
- Import-PWProjectAccessControl
Export Access Control
Get-Help Export-PWProjectAccessControl -Full
As you can see, there are multiple parameters available for the Export-PWProjectAccessControl cmdlet, and a bunch of examples.
There are three ways in which to specify the project folder to export access control for.
- InputFolder – Source ProjectWise folder object from pipeline
- FolderPath – Source folder path
- FolderID – Source folder ID
The cmdlet will ONLY accept one ProjectWise Folder object when using the InputFolder parameter inline (Export-PWProjectAccessControl -InputFolder $pwfolders), not passing the ProjectWise Folder objects via the pipeline. You will receive the following error:
We can also specify the level of folders to export access control for.
- FolderLevel – Level of folders to return access control for.
- Zero (0) is the default. Returns all access control for entire folder structure.
- One (1) will export only the source folder access control.
Finally, we can export the access control.
- ExportFilePathName – the full path and file name of the file to export the access control to.
- The specified name MUST end with either SQLite or XLSX. Otherwise, it will be exported to an Excel spreadsheet which is the default.
- Example: AccessControl.txt will result in AccessControl.txt.xlsx
NOTE: If an ExportFilePathName is NOT included, the access control objects will be returned in a datatable.
NOTE: Workflow access control entries will ONLY be exported when a folder has a workflow applied to it.
ProjectWise Project Information
The following images show the access control set on a few of the project folders.
One folder has explicit access control set.
One is inheriting access control.
And one has a workflow assigned to the folder.
Populate a Datatable with All Access Control
We are going to output the access control entries to a datatable. And then view the output using the Out-Grid cmdlet.
<# Export ONLY the specified projects access control by piping the results of the Get-PWFolders to the Export-PWProjectAccessControl cmdlet. #> $dtAccessControl = Get-PWFolders -FolderID 69212 -JustOne | Export-PWProjectAccessControl <# View the contents of the datatable by piping the contents to the Out-Gridview cmdlet. #> $dtAccessControl | Out-GridView -Title 'ProjectWise Access Control Entries' -Wait
In the following you’ll see that the access control items for the parent folder and sub-folders have been returned. You can also see which folders are inheriting access control and from where.
Export Project Access Control to SQLite Database
In this example we will be accomplishing two exports of our project access control to SQLite databases. The first one will be ONLY the project folders access control. The second will consist of two levels.
<# Populate the pwFolder variable with the project's folder object. Export ONLY the access control items for the parent folder by using FolderLevel 1. #> $pwFolder = Get-PWFolders -FolderID 69212 -JustOne # Using a splat for readability. $Splat = @{ InputFolder = $pwFolder FolderLevel = 1 ExportFilePathName = 'd:\temp\export\access\AccessControl_ProjectFolderOnly.sqlite' } Export-PWProjectAccessControl @Splat -Verbose <# Using a folder ID, export two (2) levels of access control items which will consist of the the parent folder and all immediate child folders by using FolderLevel 2. #> $Splat = @{ FolderID = 69212 FolderLevel = 2 ExportFilePathName = 'd:\temp\export\access\AccessControl_2Levels.sqlite' } Export-PWProjectAccessControl @Splat -Verbose
The following shows the two different SQLite databases that were created.
I am using SQLiteStudio to view the contents of the SQLite databases. You can download the SQLite Studio using the following link:
https://sqlitestudio.pl/index.rvt?act=download
Contents of AccessControl_ProjectFolderOnly.sqlite:
Contents of AccessControl_2Levels.sqlite:
Export Project Access Control to Excel Workbook
In this example we will be accomplishing one export of our project access control to an Excel workbook which will contain ALL access control for the entire project.
<# Using a folder path, export ALL access control items for the entire project to an Excel workbook. We could omit the FolderLevel = 0, as the default value is zero. #> $Splat = @{ FolderPath = 'PowerShell\PowerShell_Test' FolderLevel = 0 ExportFilePathName = 'd:\temp\export\access\AccessControl_All.xlsx' } Export-PWProjectAccessControl @Splat -Verbose
The following shows the Excel workbook that was created.
Contents of AccessControl_All.xlsx:
Experiment with it and have fun.
Hopefully, you find this useful. Please let me know if you have any questions or comments. If you like this post, please click the Like button at the bottom of the page.