Is there a method to embed powershell code in SSIS or T-SQL, without saving the code in an external file *.ps1? We know SSIS/Tsql can run powershell, however the code always seems to be saved somewhere else. We want powershell code embedded in SSIS package or t-sql stored procedure, which then can be executed.
Time issue with Dbas, setting up file share folders, and then deploying these powershell files into our Dev, QA, Prod environments (we have multiple servers), this can alleviate some of the Devops process.
1) The T-sql route may use xp_cmdshell which can be security issue, not sure if this is true. Is there safe way with xp_cmdshell or totally different route in T-SQL area?
2) The article below explains running Powershell in SSIS, however it is calling another file. Can we embed code in SSIS, and run powershell?
https://blogs.msdn.microsoft.com/ssis/2017/01/26/run-powershell-scripts-in-ssis/
At the end, I am trying to run a workflow parallel process. Powershell Run stored procedures in parallel in database
Workflow TestRunParallelExecute
{
$ServerName = "localhost"
$DatabaseName = "testrun"
$Procedure_Query = "select name from sys.procedures"
$Procedure_List = (Invoke-Sqlcmd -Server $ServerName -Database $DatabaseName -Query $Procedure_Query)
ForEach -Parallel ($Procedure in $Procedure_List.Name)
{
Invoke-Sqlcmd -Server $ServerName -Database $DatabaseName -Query $Procedure
}
}
TestRunParallelExecute
cls