- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个脚本可以完美地使用 Windows PowerShell 上传到 S3 存储桶,但它不适用于 PowerShell Core。根据 Amazon 的说法,大多数在一个中运行的 cmdlet 应该在另一个中运行。
这是我正在使用的命令:
Write-S3Object -BucketName $bucketName -Folder $localDir -KeyPrefix $targetFolder -AccessKey $accessKey -SecretKey $secretKey -Recurse
同样,当我尝试直接在 PowerShell 中运行命令时,它按预期工作,但在 PowerShell Core 中出现此错误:
Write-S3Object : The term 'Write-S3Object' 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:1 char:1
+ Write-S3Object -BucketName "cloud-storage-poc" -Folder "C:\Users\Admi ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Write-S3Object:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
最佳答案
对于 PowerShell Core,您需要在脚本或命令运行之前显式导入 AWSPowerShell.NetCore 模块。由于模块中有大量 cmdlet(目前超过 5000 个),我们目前无法在模块 list 中列出导出的 cmdlet 名称,并且正在探索其他替代方案(例如将来创建每个服务的模块,但还没有 ETA)。
假设有一台“干净”的机器,那么</p>
Install-Module AWSPowerShell.NetCore
Import-Module AWSPowerShell.NetCore
Write-S3Object ...
然后应该为你工作。当然,如果您已经安装了正确的模块,那么您可以跳过第一个命令。我将 Windows 和 Core 的 PowerShell 配置文件设置为始终执行导入。
对于某些人来说,为什么这在 Windows 上有效,是因为直到去年年中我们才在 list 中列出了导出的 cmdlet。然而,就在我们通过模块中的 4000 个 cmdlet 计数时,发布到 PowerShell Gallery 由于隐藏限制而被阻止并迫使我们停止列出它们。通过在 list 中列出导出的 cmdlet,PowerShell 不需要显式导入语句。
关于amazon-web-services - 使用 PowerShell Core 上传到 Amazon S3 存储桶,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53643033/
我是一名优秀的程序员,十分优秀!