I am developing an application to migrate non-table objects between various databases (across platform and cross versions) and need to be able to create and delete ODBC DSN records on the fly (for security and automation purposes).
I have been researching PowerShell on lots of forums and in the MS docs but have not been able to resolve what is going on with the following.
I am able to successfully execute
PowerShell -Command $Result = Remove-OdbcDsn -Name "scriptBroker" -DsnType "User"
from the command line but while
Add-OdbcDsn -Name "scriptBroker" -DriverName "SQL Server" -DsnType "User" -SetPropertyValue @("Server=IBT-DEV-DELL\IBT_DEMO", "Trusted_Connection=Yes")
works in PowerShell, if I pre-pend the “PowerShell -Command” syntax and execute it from the command line it fails. (error message below)
C:\Users\jtregea>PowerShell -Command $Result = Add-OdbcDsn -Name “scriptBroker” -DriverName “SQL Server” -DsnType “User” -SetPropertyValue @(“Server=IBT-DEV-DELL\IBT_DEMO”, “Trusted_Connection=Yes”)
At line:1 char:127
- … snType User -SetPropertyValue @(Server=IBT-DEV-DELL\IBT_DEMO, Trusted …
Missing argument in parameter list.
+ CategoryInfo : ParserError: ( , ParentContainsErrorRecordException
+ FullyQualifiedErrorId : MissingArgument
The IDE I am using (LiveCode) will allow me to write to shell() but I have no direct access to PowerShell from the IDE environment.
Any advice on this appreciated.