Execute powershell script from ssis?
Hi,
I was trying to use the execute process task to kick off a powershell script. However, nothing happens when I run in debug (the component turns yellow and stays yellow). Any idea if what I am trying to do is possible and the proper way to configure
it?
btw, I am using powershell for the remoting capabilites. I need to execute a bat file on a remote server which runs a process in a legacy program.
Update: When I name the ps1 script file in the executable window, it opens it in notepad. This would be like the default if you double clicked the file.
Mark
July 1st, 2010 5:06pm
Ok,
I have this working now. Here are the steps for future reference:
1 - In the executable field put the file path for powershell.exe
For me, this was located in C:\WINDOWS\system32\windowspowershell\v1.0\powershell.exe
2 - In the arguments field put the powershell command that you wish to run.
i.e. Invoke-Command -Computername Server123 {start-process C:\Test.bat -wait}
The -wait command will force the task to wait before moving on. The bat file, or whatever process you might want to execute, including powershell scripts, should be located on the target computer.
Hope this is helpful to someone.
Mark
Free Windows Admin Tool Kit Click here and download it now
July 1st, 2010 6:04pm
To run a PowerShell Script from SSIS package. Add a "Execute Process Task" in SSIS and use the following command text.
This works just great, plus the "-ExecutionPolicy ByPass" switch will take care of any server script policies.
C:\Windows\System32\WindowsPowerShell\v1.0\PowerShell.exe
-ExecutionPolicy ByPass -command ". 'L:\Powershell_Script\Script1.ps1' 'param1' 'param2'"
Regards
Deepak
May 6th, 2011 1:21pm
Thank you for the additional info on the execution policy.
My original requirement was for the remote execution of script which is why I used the Invoke-Command cmdlet.
Free Windows Admin Tool Kit Click here and download it now
May 6th, 2011 1:47pm