Execute Process Task, Passing in variables from SSIS to Powershell Script
I have been trying to build a package that can be called in an agent job to pass in paramaters for the purpose of backing up SSAS cubes. I have the code working but I can't seem to get the variables from SSIS to pass into the Powershell Script. Here is the script with my latest attempt, param($SSASServerName,$BackupLocation) $serverName = $SSASServerName $outputFolder = $BackupLocation ## load the AMO and XML assemblies into the current runspace [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.AnalysisServices") > $null [System.Reflection.Assembly]::LoadWithPartialName("System.Xml") > $null $dateStamp = (get-Date).ToString("yyyyMMdd") ## connect to the server $svr = new-Object Microsoft.AnalysisServices.Server $svr.Connect($serverName) foreach ($db in $svr.Databases) { write-Host "Scripting: " $db.Name $xw = new-object System.Xml.XmlTextWriter("$($outputFolder)DBScript_$($db.Name)_$($dateStamp).xmla", [System.Text.Encoding]::UTF8) $xw.Formatting = [System.Xml.Formatting]::Indented [Microsoft.AnalysisServices.Scripter]::WriteCreate($xw,$svr,$db,$true,$true) $xw.Close() } $svr.Disconnect() And in the Execute Process Task I try and bring them in the arguement field as C:\test\MDBackup.ps1 -$SSASServerName [User::SSASServerName] -$BackupLocation [User::BackupLocation] What is the proper way to pass in SSIS variables to a powershell script running from an Execute Process Task?
May 16th, 2011 9:24pm

You did not disclose how you coded the invocation of the PowerShell script. My thinking is you need to do it from within a DOS like command powershell -command "& {C:\Path to your PS1 file\YourFileName.ps1 ServerName BkpLocation}"Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
May 16th, 2011 11:09pm

did you set the argument property in the EXPRESSION ?http://www.rad.pasfu.com
May 17th, 2011 12:55am

I was passing in the variables incorrectly and after looking at another script and constructing the expression properly it finaly worked.
Free Windows Admin Tool Kit Click here and download it now
May 19th, 2011 2:02pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics