#region Module Import Import-Module PWPS_DAB -Verbose Import-Module SqlServer -Verbose $PWPS_DABVersion = (Get-Module -Name PWPS_DAB | Where-Object ModuleType -eq 'Binary').Version.ToString() Import-Module "C:\Program Files\WindowsPowerShell\Modules\pwps_dab\$PWPS_DABVersion\HelperFunctions.psm1" -Verbose #endregion #region Return Metrics $PWPerformanceReportVariables = @{ Connection = "Office LAN"; Location = "Melbourne, Victoria"; ConnectingViaCache = "False" Datasource = "decide-pwce-aus.bentley.com:decide-pwce-aus-010" ProjectWiseUserName = "PWUserName" ProjectWisePassword = (Get-SecureStringFromEncryptedFile -FileName C:\temp\ProjectWisePassword.txt); OutputType = "DataTable"; } $Dataset = Get-PWPerformanceReportData @PWPerformanceReportVariables -Verbose #endregion # If you do not have a target SQL database to write to, stop at this point and write to SQLite/Excel instead. #region Write to SQL $SQL = @{ SQLServer = 'TargetSQLServer'; Database = 'TargetDatabaseName'; UserName = 'sqladminusername'; Password = (Get-ClearTextFromEncryptedFile -FileName C:\temp\SQLPassword.txt) } $SQLConnection = New-SQLConnection @SQL -Verbose foreach ($Table in $Dataset.Tables) { if (!(Get-SQLTable -SQLConnection $SQLConnection -TableName $Table.TableName -ErrorAction SilentlyContinue)) { New-SQLTable -SQLConnection $SQLConnection -Database $SQL.Database -DataTable $Table } BulkCopy-SQLTable -SQLConnection $SQLConnection -DataTable $Table } #endregion