SSIS with PowerShell script to refresh Excel connections?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







2















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 = 'DOMAINbl0040ep'
$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:SVNBusinessAnalystsExcelToolsDatabaseSSAS_Usage Stats.xlsx'
$x1 = New-Object -ComObject Excel.Application
$x1.Visible = $false
$x1.DisplayAlerts = $False
$enddate = (Get-Date).tostring("dd-MM-yy")
$filename = 'C:SVNBusinessAnalystsExcelToolsDatabaseSSAS_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



ps-script_excel-refresh-2-windows.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png










share|improve this question

























  • I would like to add some more information to this requirement. I found an open source custom SSIS task on code plex SSIS Excel Refresh Task. I downloaded the files, but I am not sure how to install the custom task to. Anyone know? There are quite a few files that comes with the download, including a 'sourceCode' folder and 'Microsoft Excel Refresh Task.sln' Visual Studio Solution file. I found instructions from The Data Queen website, but I think I need more info.

    – SherlockSpreadsheets
    Jan 4 at 15:48




















2















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 = 'DOMAINbl0040ep'
$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:SVNBusinessAnalystsExcelToolsDatabaseSSAS_Usage Stats.xlsx'
$x1 = New-Object -ComObject Excel.Application
$x1.Visible = $false
$x1.DisplayAlerts = $False
$enddate = (Get-Date).tostring("dd-MM-yy")
$filename = 'C:SVNBusinessAnalystsExcelToolsDatabaseSSAS_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



ps-script_excel-refresh-2-windows.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png










share|improve this question

























  • I would like to add some more information to this requirement. I found an open source custom SSIS task on code plex SSIS Excel Refresh Task. I downloaded the files, but I am not sure how to install the custom task to. Anyone know? There are quite a few files that comes with the download, including a 'sourceCode' folder and 'Microsoft Excel Refresh Task.sln' Visual Studio Solution file. I found instructions from The Data Queen website, but I think I need more info.

    – SherlockSpreadsheets
    Jan 4 at 15:48
















2












2








2








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 = 'DOMAINbl0040ep'
$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:SVNBusinessAnalystsExcelToolsDatabaseSSAS_Usage Stats.xlsx'
$x1 = New-Object -ComObject Excel.Application
$x1.Visible = $false
$x1.DisplayAlerts = $False
$enddate = (Get-Date).tostring("dd-MM-yy")
$filename = 'C:SVNBusinessAnalystsExcelToolsDatabaseSSAS_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



ps-script_excel-refresh-2-windows.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png










share|improve this question
















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 = 'DOMAINbl0040ep'
$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:SVNBusinessAnalystsExcelToolsDatabaseSSAS_Usage Stats.xlsx'
$x1 = New-Object -ComObject Excel.Application
$x1.Visible = $false
$x1.DisplayAlerts = $False
$enddate = (Get-Date).tostring("dd-MM-yy")
$filename = 'C:SVNBusinessAnalystsExcelToolsDatabaseSSAS_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



ps-script_excel-refresh-2-windows.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



SSISDB-IsolatedPackages-SSASUsageStats.dtsx.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png



exceldataset-DBA.dbo.UsageStatsLogOLAP.png







sql-server excel powershell ssis permissions






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 5 at 14:12







SherlockSpreadsheets

















asked Jan 4 at 14:38









SherlockSpreadsheetsSherlockSpreadsheets

574416




574416













  • I would like to add some more information to this requirement. I found an open source custom SSIS task on code plex SSIS Excel Refresh Task. I downloaded the files, but I am not sure how to install the custom task to. Anyone know? There are quite a few files that comes with the download, including a 'sourceCode' folder and 'Microsoft Excel Refresh Task.sln' Visual Studio Solution file. I found instructions from The Data Queen website, but I think I need more info.

    – SherlockSpreadsheets
    Jan 4 at 15:48





















  • I would like to add some more information to this requirement. I found an open source custom SSIS task on code plex SSIS Excel Refresh Task. I downloaded the files, but I am not sure how to install the custom task to. Anyone know? There are quite a few files that comes with the download, including a 'sourceCode' folder and 'Microsoft Excel Refresh Task.sln' Visual Studio Solution file. I found instructions from The Data Queen website, but I think I need more info.

    – SherlockSpreadsheets
    Jan 4 at 15:48



















I would like to add some more information to this requirement. I found an open source custom SSIS task on code plex SSIS Excel Refresh Task. I downloaded the files, but I am not sure how to install the custom task to. Anyone know? There are quite a few files that comes with the download, including a 'sourceCode' folder and 'Microsoft Excel Refresh Task.sln' Visual Studio Solution file. I found instructions from The Data Queen website, but I think I need more info.

– SherlockSpreadsheets
Jan 4 at 15:48







I would like to add some more information to this requirement. I found an open source custom SSIS task on code plex SSIS Excel Refresh Task. I downloaded the files, but I am not sure how to install the custom task to. Anyone know? There are quite a few files that comes with the download, including a 'sourceCode' folder and 'Microsoft Excel Refresh Task.sln' Visual Studio Solution file. I found instructions from The Data Queen website, but I think I need more info.

– SherlockSpreadsheets
Jan 4 at 15:48














1 Answer
1






active

oldest

votes


















1














This sounds like a painful process. If it was me, I'd skip the Excel + Powerquery bits in the SSIS package. Just load the data from the DMV views (with a timestamp) directly into tables. Preferably SQL Server 2016 temporal tables.



Then, set up an Excel spreadsheet outside of SSIS process, for the end users, that pulls data from temporal table queries. Due to the nature of the temporal table queries, the default segment/window on them will always be "latest" (however it's defined for the temporal table...).



You could then parameterize the time segment sent back to the temporal queries to capture different windows - set up an Excel list of "quanta" to send to the temporal query, the user picks a value from the list, which then triggers the data refreshes for that "quantum".



If you can use SQL Server 2016+, do some research into temporal tables and queries. It sounds like they would facilitate what it seems like you're trying to do here.



In the Excel workbook (.xlsm), you can then have it refresh the PowerQuery data upon opening of the workbook, which should always get it to be "latest" data.



Excel isn't usually a very good tool to put into the middle of an automated data analysis process. It is primarily a user end-point tool.



There are plenty of Powershell scripts to "drive" Excel (thru COM Interop) if you need to do it this way. This leaves the Powershell process invoked from SSIS in charge of tearing down the COM objects when the Powershell process ends.



Automating Excel thru COM Interop on a server runs the risk of things not exiting Excel completely, which will result in lots of Excel zombie processes sucking up resources. So that leaves setting up another process that periodically kills of Excel zombie processes... (and there are examples on the nets for how to do this, too) if you can't completely clean up [sic] after Excel.



If you have to create Excel files from a server process (which SSIS would be...), I've had success in the past using the EPPlus .Net DLL with Powershell scripts in SSIS. Powershell gets the data, then invokes EPPlus write data directly to Excel files (.xlsx) w/o requiring or interacting with Excel.exe. (reading works, too).



The "NPOI.dll" library is a .Net port of the Java "POI" library, which can also write to "Excel.Old" (.xls) files as well as .xlsx files. It works similarly to EPPlus.



The big advantage of either of these (which I suspect you noticed that Powerquery doesn't do to data either...) is that you can sidestep the "help" that Excel will apply to the data being loaded into the workbook. (e.g., with EPPlus you can push zip codes or US SSNs into cells as text values - you are in control of cell styles and display format. Excel will "help" you by converting these to numeric data, thus losing any leading 0's... trying to overcome this anti-help involves any number of different kludges).






share|improve this answer


























  • Thanks for all the information. I ended up changing the SSIS package datasource from Excel to OLE DB Provider for Analysis Services 12.0. I then loaded the data into SQL Server, and had additional SQL objects (stored proc, view) that further processed the data into the format I had achieved (but not automated) in Excel PQ. The lesson learned is exactly as you put it... Excel isn't usually a very good tool to put into the middle of an automated data analysis process.

    – SherlockSpreadsheets
    Mar 26 at 17:51












Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54041047%2fssis-with-powershell-script-to-refresh-excel-connections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














This sounds like a painful process. If it was me, I'd skip the Excel + Powerquery bits in the SSIS package. Just load the data from the DMV views (with a timestamp) directly into tables. Preferably SQL Server 2016 temporal tables.



Then, set up an Excel spreadsheet outside of SSIS process, for the end users, that pulls data from temporal table queries. Due to the nature of the temporal table queries, the default segment/window on them will always be "latest" (however it's defined for the temporal table...).



You could then parameterize the time segment sent back to the temporal queries to capture different windows - set up an Excel list of "quanta" to send to the temporal query, the user picks a value from the list, which then triggers the data refreshes for that "quantum".



If you can use SQL Server 2016+, do some research into temporal tables and queries. It sounds like they would facilitate what it seems like you're trying to do here.



In the Excel workbook (.xlsm), you can then have it refresh the PowerQuery data upon opening of the workbook, which should always get it to be "latest" data.



Excel isn't usually a very good tool to put into the middle of an automated data analysis process. It is primarily a user end-point tool.



There are plenty of Powershell scripts to "drive" Excel (thru COM Interop) if you need to do it this way. This leaves the Powershell process invoked from SSIS in charge of tearing down the COM objects when the Powershell process ends.



Automating Excel thru COM Interop on a server runs the risk of things not exiting Excel completely, which will result in lots of Excel zombie processes sucking up resources. So that leaves setting up another process that periodically kills of Excel zombie processes... (and there are examples on the nets for how to do this, too) if you can't completely clean up [sic] after Excel.



If you have to create Excel files from a server process (which SSIS would be...), I've had success in the past using the EPPlus .Net DLL with Powershell scripts in SSIS. Powershell gets the data, then invokes EPPlus write data directly to Excel files (.xlsx) w/o requiring or interacting with Excel.exe. (reading works, too).



The "NPOI.dll" library is a .Net port of the Java "POI" library, which can also write to "Excel.Old" (.xls) files as well as .xlsx files. It works similarly to EPPlus.



The big advantage of either of these (which I suspect you noticed that Powerquery doesn't do to data either...) is that you can sidestep the "help" that Excel will apply to the data being loaded into the workbook. (e.g., with EPPlus you can push zip codes or US SSNs into cells as text values - you are in control of cell styles and display format. Excel will "help" you by converting these to numeric data, thus losing any leading 0's... trying to overcome this anti-help involves any number of different kludges).






share|improve this answer


























  • Thanks for all the information. I ended up changing the SSIS package datasource from Excel to OLE DB Provider for Analysis Services 12.0. I then loaded the data into SQL Server, and had additional SQL objects (stored proc, view) that further processed the data into the format I had achieved (but not automated) in Excel PQ. The lesson learned is exactly as you put it... Excel isn't usually a very good tool to put into the middle of an automated data analysis process.

    – SherlockSpreadsheets
    Mar 26 at 17:51
















1














This sounds like a painful process. If it was me, I'd skip the Excel + Powerquery bits in the SSIS package. Just load the data from the DMV views (with a timestamp) directly into tables. Preferably SQL Server 2016 temporal tables.



Then, set up an Excel spreadsheet outside of SSIS process, for the end users, that pulls data from temporal table queries. Due to the nature of the temporal table queries, the default segment/window on them will always be "latest" (however it's defined for the temporal table...).



You could then parameterize the time segment sent back to the temporal queries to capture different windows - set up an Excel list of "quanta" to send to the temporal query, the user picks a value from the list, which then triggers the data refreshes for that "quantum".



If you can use SQL Server 2016+, do some research into temporal tables and queries. It sounds like they would facilitate what it seems like you're trying to do here.



In the Excel workbook (.xlsm), you can then have it refresh the PowerQuery data upon opening of the workbook, which should always get it to be "latest" data.



Excel isn't usually a very good tool to put into the middle of an automated data analysis process. It is primarily a user end-point tool.



There are plenty of Powershell scripts to "drive" Excel (thru COM Interop) if you need to do it this way. This leaves the Powershell process invoked from SSIS in charge of tearing down the COM objects when the Powershell process ends.



Automating Excel thru COM Interop on a server runs the risk of things not exiting Excel completely, which will result in lots of Excel zombie processes sucking up resources. So that leaves setting up another process that periodically kills of Excel zombie processes... (and there are examples on the nets for how to do this, too) if you can't completely clean up [sic] after Excel.



If you have to create Excel files from a server process (which SSIS would be...), I've had success in the past using the EPPlus .Net DLL with Powershell scripts in SSIS. Powershell gets the data, then invokes EPPlus write data directly to Excel files (.xlsx) w/o requiring or interacting with Excel.exe. (reading works, too).



The "NPOI.dll" library is a .Net port of the Java "POI" library, which can also write to "Excel.Old" (.xls) files as well as .xlsx files. It works similarly to EPPlus.



The big advantage of either of these (which I suspect you noticed that Powerquery doesn't do to data either...) is that you can sidestep the "help" that Excel will apply to the data being loaded into the workbook. (e.g., with EPPlus you can push zip codes or US SSNs into cells as text values - you are in control of cell styles and display format. Excel will "help" you by converting these to numeric data, thus losing any leading 0's... trying to overcome this anti-help involves any number of different kludges).






share|improve this answer


























  • Thanks for all the information. I ended up changing the SSIS package datasource from Excel to OLE DB Provider for Analysis Services 12.0. I then loaded the data into SQL Server, and had additional SQL objects (stored proc, view) that further processed the data into the format I had achieved (but not automated) in Excel PQ. The lesson learned is exactly as you put it... Excel isn't usually a very good tool to put into the middle of an automated data analysis process.

    – SherlockSpreadsheets
    Mar 26 at 17:51














1












1








1







This sounds like a painful process. If it was me, I'd skip the Excel + Powerquery bits in the SSIS package. Just load the data from the DMV views (with a timestamp) directly into tables. Preferably SQL Server 2016 temporal tables.



Then, set up an Excel spreadsheet outside of SSIS process, for the end users, that pulls data from temporal table queries. Due to the nature of the temporal table queries, the default segment/window on them will always be "latest" (however it's defined for the temporal table...).



You could then parameterize the time segment sent back to the temporal queries to capture different windows - set up an Excel list of "quanta" to send to the temporal query, the user picks a value from the list, which then triggers the data refreshes for that "quantum".



If you can use SQL Server 2016+, do some research into temporal tables and queries. It sounds like they would facilitate what it seems like you're trying to do here.



In the Excel workbook (.xlsm), you can then have it refresh the PowerQuery data upon opening of the workbook, which should always get it to be "latest" data.



Excel isn't usually a very good tool to put into the middle of an automated data analysis process. It is primarily a user end-point tool.



There are plenty of Powershell scripts to "drive" Excel (thru COM Interop) if you need to do it this way. This leaves the Powershell process invoked from SSIS in charge of tearing down the COM objects when the Powershell process ends.



Automating Excel thru COM Interop on a server runs the risk of things not exiting Excel completely, which will result in lots of Excel zombie processes sucking up resources. So that leaves setting up another process that periodically kills of Excel zombie processes... (and there are examples on the nets for how to do this, too) if you can't completely clean up [sic] after Excel.



If you have to create Excel files from a server process (which SSIS would be...), I've had success in the past using the EPPlus .Net DLL with Powershell scripts in SSIS. Powershell gets the data, then invokes EPPlus write data directly to Excel files (.xlsx) w/o requiring or interacting with Excel.exe. (reading works, too).



The "NPOI.dll" library is a .Net port of the Java "POI" library, which can also write to "Excel.Old" (.xls) files as well as .xlsx files. It works similarly to EPPlus.



The big advantage of either of these (which I suspect you noticed that Powerquery doesn't do to data either...) is that you can sidestep the "help" that Excel will apply to the data being loaded into the workbook. (e.g., with EPPlus you can push zip codes or US SSNs into cells as text values - you are in control of cell styles and display format. Excel will "help" you by converting these to numeric data, thus losing any leading 0's... trying to overcome this anti-help involves any number of different kludges).






share|improve this answer















This sounds like a painful process. If it was me, I'd skip the Excel + Powerquery bits in the SSIS package. Just load the data from the DMV views (with a timestamp) directly into tables. Preferably SQL Server 2016 temporal tables.



Then, set up an Excel spreadsheet outside of SSIS process, for the end users, that pulls data from temporal table queries. Due to the nature of the temporal table queries, the default segment/window on them will always be "latest" (however it's defined for the temporal table...).



You could then parameterize the time segment sent back to the temporal queries to capture different windows - set up an Excel list of "quanta" to send to the temporal query, the user picks a value from the list, which then triggers the data refreshes for that "quantum".



If you can use SQL Server 2016+, do some research into temporal tables and queries. It sounds like they would facilitate what it seems like you're trying to do here.



In the Excel workbook (.xlsm), you can then have it refresh the PowerQuery data upon opening of the workbook, which should always get it to be "latest" data.



Excel isn't usually a very good tool to put into the middle of an automated data analysis process. It is primarily a user end-point tool.



There are plenty of Powershell scripts to "drive" Excel (thru COM Interop) if you need to do it this way. This leaves the Powershell process invoked from SSIS in charge of tearing down the COM objects when the Powershell process ends.



Automating Excel thru COM Interop on a server runs the risk of things not exiting Excel completely, which will result in lots of Excel zombie processes sucking up resources. So that leaves setting up another process that periodically kills of Excel zombie processes... (and there are examples on the nets for how to do this, too) if you can't completely clean up [sic] after Excel.



If you have to create Excel files from a server process (which SSIS would be...), I've had success in the past using the EPPlus .Net DLL with Powershell scripts in SSIS. Powershell gets the data, then invokes EPPlus write data directly to Excel files (.xlsx) w/o requiring or interacting with Excel.exe. (reading works, too).



The "NPOI.dll" library is a .Net port of the Java "POI" library, which can also write to "Excel.Old" (.xls) files as well as .xlsx files. It works similarly to EPPlus.



The big advantage of either of these (which I suspect you noticed that Powerquery doesn't do to data either...) is that you can sidestep the "help" that Excel will apply to the data being loaded into the workbook. (e.g., with EPPlus you can push zip codes or US SSNs into cells as text values - you are in control of cell styles and display format. Excel will "help" you by converting these to numeric data, thus losing any leading 0's... trying to overcome this anti-help involves any number of different kludges).







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 26 at 17:20

























answered Mar 26 at 17:00









user1390375user1390375

16413




16413













  • Thanks for all the information. I ended up changing the SSIS package datasource from Excel to OLE DB Provider for Analysis Services 12.0. I then loaded the data into SQL Server, and had additional SQL objects (stored proc, view) that further processed the data into the format I had achieved (but not automated) in Excel PQ. The lesson learned is exactly as you put it... Excel isn't usually a very good tool to put into the middle of an automated data analysis process.

    – SherlockSpreadsheets
    Mar 26 at 17:51



















  • Thanks for all the information. I ended up changing the SSIS package datasource from Excel to OLE DB Provider for Analysis Services 12.0. I then loaded the data into SQL Server, and had additional SQL objects (stored proc, view) that further processed the data into the format I had achieved (but not automated) in Excel PQ. The lesson learned is exactly as you put it... Excel isn't usually a very good tool to put into the middle of an automated data analysis process.

    – SherlockSpreadsheets
    Mar 26 at 17:51

















Thanks for all the information. I ended up changing the SSIS package datasource from Excel to OLE DB Provider for Analysis Services 12.0. I then loaded the data into SQL Server, and had additional SQL objects (stored proc, view) that further processed the data into the format I had achieved (but not automated) in Excel PQ. The lesson learned is exactly as you put it... Excel isn't usually a very good tool to put into the middle of an automated data analysis process.

– SherlockSpreadsheets
Mar 26 at 17:51





Thanks for all the information. I ended up changing the SSIS package datasource from Excel to OLE DB Provider for Analysis Services 12.0. I then loaded the data into SQL Server, and had additional SQL objects (stored proc, view) that further processed the data into the format I had achieved (but not automated) in Excel PQ. The lesson learned is exactly as you put it... Excel isn't usually a very good tool to put into the middle of an automated data analysis process.

– SherlockSpreadsheets
Mar 26 at 17:51




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54041047%2fssis-with-powershell-script-to-refresh-excel-connections%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Monofisismo

Angular Downloading a file using contenturl with Basic Authentication

Olmecas