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.
I had a request come in where a user wanted a report listing which attributes were used on each of their ProjectWise Interfaces for a specific ProjectWise Environment.
First thing I did, was create a couple of variables. One for the report path and name. And the other for the ProjectWise Environment name.
$OutputFilePathName = 'D:\Export\PWInterface_Attributes.xlsx' $EnvironmentName = 'MyEnvironment'
Next, I created an Array list to populate with a datatable for each of the Interfaces.
$dtArray = New-Object System.Collections.ArrayList
I then looped through each of the ProjectWise Interfaces. For each of the interfaces found, I created a datatable using the Interface name as the datatable name to differentiate within the report. I then, obtained the GUI definition, and added each column/attribute name to the datatable. Finally, I added the datatable to the datatable arraylist.
foreach ($interface in (Get-PWInterfaces).Values) { # Create new datatable with the name of the current interface. $dt = New-Object System.Data.DataTable ($interface) # Add a column to the datatable named 'Attibute Name'. $dt.Columns.Add('Attribute Name') # Get all of the column/attribute names for the current interface. # Sort the column names, and add each to the datatable. (Get-PWInterfaceGUIDefinition -EnvironmentName $EnvironmentName -InterfaceName $interface -Verbose).'Column Name' | Sort-Object | ForEach-Object ( { $dt.Rows.Add($_) } ) # Add the datatable to the datatable arraylist. $dtArray.Add($dt) }
The final step in the process is to create the report. I used the New-XLSXWorkbook cmdlet to export all of the datatables contained in the datatable array to the Excel workbook specified in the $OutputFilePathName variable. The resulting worksheet will contain a tab for each of the interfaces contained within the ProjectWise datasource.
New-XLSXWorkbook -InputTables $dtArray -OutputFileName $OutputFilePathName -Open -Verbose
Hopefully, this all makes sense and you find it useful.