You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用PowerShell的Add-OdbcDsn时,如何通过-SetPropertyValue添加文件路径?

解决Add-OdbcDsn设置BigQuery ODBC驱动文件路径无效的问题

你遇到的文件路径无法生效的问题,主要有两个常见原因及对应解决方法:

原因1:ODBC驱动的属性名实际不带空格

很多Simba ODBC驱动的UI显示名称和底层API使用的属性名不一致,比如UI里的「Key File Path」,底层实际属性名是KeyFilePath(无空格)。

修正后的脚本:

Add-OdbcDsn -Name "My_Connew" -DriverName "Simba ODBC Driver for Google BigQuery" -DsnType "System" -Platform "64-bit" -SetPropertyValue @(
    "Email=246384378418-compute@developer.gserviceaccount.com",
    "KeyFilePath=C:\vocus-sandpit-dfa36ce40776.json"
)

原因2:PowerShell字符串转义问题

如果确认属性名确实是「Key File Path」,那问题出在路径的反斜杠上——PowerShell双引号字符串里的单个反斜杠会被当作转义符处理,导致路径解析错误。可以用两种方式解决:

方式A:使用双反斜杠转义

Add-OdbcDsn -Name "My_Connew" -DriverName "Simba ODBC Driver for Google BigQuery" -DsnType "System" -Platform "64-bit" -SetPropertyValue @(
    "Email=246384378418-compute@developer.gserviceaccount.com",
    "Key File Path=C:\\vocus-sandpit-dfa36ce40776.json"
)

方式B:用单引号包裹键值对

单引号字符串在PowerShell里不会解析转义符,能保留原路径格式:

Add-OdbcDsn -Name "My_Connew" -DriverName "Simba ODBC Driver for Google BigQuery" -DsnType "System" -Platform "64-bit" -SetPropertyValue @(
    'Email=246384378418-compute@developer.gserviceaccount.com',
    'Key File Path=C:\vocus-sandpit-dfa36ce40776.json'
)

建议先尝试第一种方法(修改属性名为KeyFilePath),这是Simba驱动这类问题的最常见解决方案。

内容的提问来源于stack exchange,提问作者Avi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 14:01:14