powershell - GCloud powershell 命令抛出错误,但在 cmd 中工作正常
问题描述
当我通过 Windows cmd 提示运行 GCloud commannds 时,它可以工作。
但是当我通过 powershell 运行它们时,它会抛出一个红色错误,但命令会成功完成。
例如:
1) 授权
gcloud auth activate-service-account xxx@xxx-xxx.iam.gserviceaccount.com --key-file=C:\xxxxx\cred.json
错误:
python.exe : Activated service account credentials for: [xxxx@xxxx.iam.gserviceaccount.com]
At xxxxxxxxxxxx\gcloud.ps1:117 char:3
+ & "$cloudsdk_python" $run_args_array
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Activated servi...iceaccount.com]:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
2)上传文件到存储桶
gsutil cp $outputFile gs://bucketxxx
错误:
gsutil : Copying file://N:\out\sqlserver\tag.csv [Content-Type=application/vnd.ms-excel]...
At xxxxxxx\RDS_SQLServer_ExportData_DataWarehouse.ps1:38 char:5
+ gsutil cp $outputFile gs://bucketxxx | out-null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Copying file://...nd.ms-excel]...:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
/ [0 files][ 0.0 B/ 2.8 MiB]
/ [1 files][ 2.8 MiB/ 2.8 MiB]
Operation completed over 1 objects/2.8 MiB.
解决方案
我无法发表评论,因此在此处添加我的输入。
首先:该问题似乎仅在通过 Powershell ISE 运行时出现,而不是在通过 powershell 提示符执行时出现。
第二:这不是这样的错误,例如,当您看到自己的错误时,您会发现未指定为“已激活的服务...”之后的文本表示操作已成功执行。希望这有助于其他人在这里磕磕绊绊
python.exe : Activated service account credentials for: [xxxx@xxxx.iam.gserviceaccount.com]
At xxxxxxxxxxxx\gcloud.ps1:117 char:3
+ & "$cloudsdk_python" $run_args_array
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Activated servi...iceaccount.com]:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
推荐阅读
- python - `@before_request` 装饰器中的访问路径变量(例如`/users/ 中的`user_id`
`) - asp.net - 将 gcServer enabled 设置为 false 不起作用
- javascript - 丢弃 useDrop hooks api 的规范总是采用初始状态而不是更新状态
- docker - 即使服务器停止,我们是否可以为在容器内运行的 websphere 应用程序服务器保持端口打开?
- flutter - FloatingActionButton 上下滚动
- increment - 如何制作能够读写 1 和 0 的图灵机?C#
- c# - 无法使用 Serilog 序列化对象
- javascript - 在 JavaScript 中循环使用表情符号
- c++ - 为什么比较结果不符合预期?
- c++ - Boost spirit X3:如果在另一种情况下可以为nullopt的可选情况如何处理?