我的操作系統是Windows 10,我使用PowerShell來嘗試創建一個DSN條目 這是我用過的命令:SetPropertyValue在不承認PowerShell中
Add-OdbcDsn -Name MyTest2 -DriverName "SQL Server Native Client 11.0" -DsnType System
-SetPropertyValue @("Server=MyServer", "Description=My second Test","User=MyTestUser","Password=12345", "Database=MyTestDB")
DSN的條目被創建,但我得到這個錯誤:
-SetPropertyValue : The term '-SetPropertyValue' 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.
At line:2 char:5
+ -SetPropertyValue @("Server=MyServer", "Description=My se ...
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (-SetPropertyValue:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
請告知我的聲明中出現了什麼問題,如果可能的話如何解決?
更新:
我加入了2線
Add-OdbcDsn -Name MyTest3 -DriverName "SQL Server Native Client 11.0" -DsnType System -Platform '32-bit' -SetPropertyValue @("Server=MyServer", "Description=My second Test","User=MyTestUser","Password=12345", "Database=TestDB")
,我得到這個錯誤:
Add-OdbcDsn : Invalid keyword-value pairs (Installer error code: 8).
At line:1 char:1
+ Add-OdbcDsn -Name MyTest3 -DriverName "SQL Server Native Client 11.0" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (MyTest2 (32-bit ODBC System DSN):Root/Microsoft/...SFT_OdbcDsnTask) [Add-OdbcD
sn], CimException
+ FullyQualifiedErrorId : MI RESULT 0,Add-OdbcDsn
Add-OdbcDsn : Driver's ConfigDSN, ConfigDriver, or ConfigTranslator failed (Installer error code: 11).
At line:1 char:1
+ Add-OdbcDsn -Name MyTest3 -DriverName "SQL Serv
參數不會自動連接到上一行,因此您需要'在上一行的末尾。 [如何輸入多行命令?](// stackoverflow.com/q/3235850) – wOxxOm
我明白了......謝謝!我在一行中加入了它們,但是我仍然遇到了錯誤...請參閱我的更新 – user1205746
我剛剛更新了一行中的所有內容 – user1205746