Using Powershell run SSIS Package(.dtsx file)

Jerry_2424 0 Reputation points
2024-02-07T07:31:30.2633333+00:00

I am trying below code(in .dtsx) :- Clear-Host # Define the path to the 32-bit dtexec.exe $dtexecPath = "C:\Program Files (x86)\Microsoft SQL Server\130\DTS\Binn\dtexec.exe" # Define the path to the SSIS package (.dtsx file) $packagePath = "E:\Practice_SSIS\All_Package\Demo\Demo\Demo\Demo\Demo.dtsx" # Build the command to execute the SSIS package $command = "& '$dtexecPath' '/FILE $packagePath /SET \Package.Variables[User::Variable1].Properties[Value];"1" /SET \Package.Variables[User::Variable2].Properties[ConnectionString];"Data Source=Demo;Initial Catalog=Demo;Integrated Security=SSPI;Auto Translate=True;" ' "  # Execute the command Invoke-Expression $command | Out-Null

How can I connect SSMS server with this code it is possible to make connection for one or more server?? Output :-- Initial : The term 'Initial' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

SQL Server Integration Services
Windows for business | Windows Server | User experience | PowerShell
SQL Server | Other
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Olaf Helper 47,586 Reputation points
    2024-02-07T07:44:31.19+00:00

    s[ConnectionString];"Data Source=Demo;Initial Catalog=Demo;Integrated Security=SSPI;Auto Translate=True;"

    If you want to define a string within a string, then you have to quote the quotation marks; you can already see it on the syntax higligthning that it is wrong: User's image

    $command = "...
    
    

  2. ZoeHui-MSFT 41,536 Reputation points
    2024-02-08T01:39:22.5366667+00:00

    Hi @Jerry_2424,

    Not familiar with Powershell, you may take a reference to this thread. Regards, Zoe Hui


    If the answer is helpful, please click "Accept Answer" and upvote it.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.