I am building an SSIS package to capture Analysis Services DMV data records into persisted SQL tables for analyzing user sessions.
Here is the process I am trying to create:
The Analysis Services DMV
[DISCOVER_SESSIONS]
on server 'Server-A' is used as the data source. On 'Server-B' the SSIS package[SSISDB/IsolatedPackages/SSASUsageStats.dtsx]
writes to custom DB table[DBA].[dbo].[UsageStatsLogOLAP]
.The source is extracted and transformed with Excel Powerquery, loaded to Excel, and transferred to SQL Server table from Excel. SSIS executes the Excel refresh and data transfer to SQL Server. After the SSIS package is complete an Excel dataset is loaded into SQL Server to add the new records. Excel sample dataset is demonstrated below.(NOTE: Excel Powerquery was chosen as the data extract ETL tool because of its simplicity to extract the 'CubeCommand' field [substring analysis], and the 'ADUserNameDisplay' field [Active Directory lookup from ‘SESSION_USER_NAME’]).
This enables the analysis of user OLAP sessions overtime. The SSIS package will be run as a SQL Agent job every 15 minutes to add new sessions to the custom SQL Server table.
Help needed:
Is there a means in SSIS to execute the PowerShell script for SSIS to refresh Excel connections? Also, keeping in mind that credentials to Analysis Services instance needed to authenticate the package? Is there a better method to refresh Excel (instead of PowerShell in SSIS)?
Some refresh options I have looked into...
SSIS PowerShell script
SSIS VB script
SSIS C# script
3-party SSIS software (CozyRoc, PowerPack, TaskFactory)
According to the the Task Factory website, the Pro Version ($2,495 - Per Server) includes a component "Excel Power Refresh Task". Does anyone have any experience with this addin? I have not tried downloading this extension.
Please see below for the PoSH scripts used so far. The package is functional but not yet automated. I need help regarding the automation of the Excel refresh to complete the package. Insights are appreciated... Thanks!
Method: Power Shell script command:
The issue with this command is that it opens a second power shell window. If I run this in 2 separate scripts the Excel workbook does update successfully. If I run this as a single script it uses my user credentials (instead of the supplied user credentials)-- the Excel file is saved successfully, but the data data refresh does not succeed.
##### STEP 1 ######
# Run powershell as another user account (DOMAIN\?????), for accessing the GCOP039 OLAP DMV
cd C:
# REM: Define domain username and password
$username = 'DOMAIN\bl0040ep'
$password = '!mySecretPwd'
# REM: Convert to a single set of credentials
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $username, $securePassword
# REM: Launch PowerShell (runas) as another user
Start-Process powershell.exe -Credential $credential #-WindowStyle Maximized
##### STEP 2 ######
# Refresh the excel workbook connections and save the updated file
$file = 'C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_Usage Stats.xlsx'
$x1 = New-Object -ComObject Excel.Application
$x1.Visible = $false
$x1.DisplayAlerts = $False
$enddate = (Get-Date).tostring("dd-MM-yy")
$filename = 'C:\SVN\BusinessAnalysts\ExcelTools\DatabaseSSAS_Usage Stats ' + $enddate + '.xlsx'
$wb = $x1.workbooks.Open($file)
$wb.refreshall()
# REM: Use SLEEP to eliminate the message: "This will cancel a pending data refresh. Continue?"
Start-Sleep -Second 20
$wb.SaveAs($filename)
$wb.Close()
$x1.Quit()
Remove-Variable wb,x1
References:
- https://www.youtube.com/watch?v=gWJgYqYhjPo&index=9&list=PLBXFmpniYyOL8foPfqviOtzYEH2yE8jeP&t=0s
- Powershell Script - Open Excel, Update External Data, Save as
Method: custom SSIS Extensions (CozyRoc, PowerPack, TaskFactory):
CozyRoc
During development, we attempted using a custom SSIS Extension (‘Excel Source Plus’ task from CozyRoc) to leverage the ‘Recalculation’ setting to refresh the Excel workbook. This did not work as advertised and when I contacted CozyRoc support staff they also verified, stating: “We do not support refresh of external data connections”.
Task Factory
According to the the Task Factory website, the Pro Version ($2,495 - Per Server) includes a component "Excel Power Refresh Task". Does anyone have any experience with this addin? I have not tried downloading this extension.
References:
- https://www.capterra.com/integration-software/compare/146853-111875-170286-178934/API-Driver-vs-COZYROC-SSIS+-Library-vs-SSIS-PowerPack-vs-Task-Factory
- https://www.sentryone.com/products/task-factory/features?hsCtaTracking=dc730d58-98cf-4332-94ea-43a5a80a7c6c%7C694de72f-7002-4ace-97a9-e00d9c08ae0f
- https://www.cozyroc.com/ssis/excel-api
Screenshots
ps-script_excel-refresh-2-windows.png
SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png
exceldataset-DBA.dbo.UsageStatsLogOLAP.png