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
Import Access Control
Get-Help Import-PWProjectAccessControl -Full
There are only two parameters available for the Import-PWProjectAccessControl cmdlet.
- InputFolder – Target folder object from pipeline.
- If excluded, a datatable will be returned.
The cmdlet will ONLY accept one ProjectWise Folder object when using the InputFolder parameter inline (Import-PWProjectAccessControl -InputFolder $pwfolders), not passing the ProjectWise Folder objects via the pipeline. You will receive the following error:
- ImportFilePathName – the full path and file name of the file to import the access control from.
- The specified name MUST end with either SQLite or XLSX. Otherwise, you will receive a warning message and the import will stop.
NOTE: If an ImportFolder is NOT included, the access control objects imported will be returned in a datatable.
ProjectWise Target Project Information
The following images show the current access control set on a few of the target project folders.
The parent folder has explicit access control set and most all subfolders are inheriting access control from it.
One folder (SubFolder_01a) has access control explicitly set. This is to demonstrate how the import process will update the access control regardless of the current settings.
Populate a Datatable with Access Control
We are going to import the access control entries to a datatable. And then view the output using the Out-Grid cmdlet.
<# Import the access control entries to a datatable. #> $dtAccessControl = Import-PWProjectAccessControl -ImportFilePathName 'D:\temp\export\access\AccessControl_2Levels.sqlite' <# 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 imported access control items.
Notice in the FullPath that we are dealing with two levels of folders, the project folder and its immediate child folders.
Import Project Access Control from SQLite Database
In this example we will be importing the access control items from a SQLite database and updating the target project access control. The access control being imported will only affect two levels of folders.
<# Populate the pwFolder variable with the target project's folder object. Update the access control based on the information imported. Only two levels should be updated. #> $pwFolder = Get-PWFolders -FolderID 69963 -JustOne # Using a splat for readability. $Splat = @{ InputFolder = $pwFolder ImportFilePathName = 'd:\temp\export\access\AccessControl_2Levels.sqlite' } Import-PWProjectAccessControl @Splat -Verbose
After running the import process, only the project folder and the immediate child folders are updated.
The following images show how the access control was updated.
In this image, you can see that the access control for the project folder has been updated. The access control is still explicitly set.
In this image, you can see that the access control for the SubFolder_01 is still inheriting its access control, however it has been updated to reflect the changes to the parent folder.
In this image, you can see that the access control for the SubFolder_01a folder has NOT been updated. That is because this folder is at the third level and was not updated in the process.
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.