【问题标题】:The command was found in the module, but the module could not be loaded在模块中找到该命令,但无法加载该模块
【发布时间】:2019-02-01 20:16:21
【问题描述】:

我正在尝试使用 PowerShell 在 cosmosdb 中创建文档。该命令在 Linux 上的 PSCore 上运行,执行策略为 Unrestricted 且不可更改。

我遇到了这个错误:

New-CosmosDbDocument:“New-CosmosDbDocument”命令位于 模块“CosmosDB”,但无法加载该模块。更多 信息,运行“Import-Module CosmosDB”

代码如下:

Import-Module CosmosDB

$Guid = $([Guid]::NewGuid().ToString())
$document = @" { ... } "@

$cosmosDbContext = New-CosmosDbContext -Account $CosmosDbAccountName
-Database $DatabaseName -ResourceGroup $ResourceGroupName     New-CosmosDbDocument -Context $cosmosDbContext -CollectionId $CollectionId -DocumentBody $document -PartitionKey "$Guid"

【问题讨论】:

  • 嗨,你有 install-module -Name CosmosDB 吗?请仅尝试 import-module -Name CosmosDB
  • 在这个 GitHub github.com/PlagueHO/CosmosDB 他们使用“import-module -Name CosmosDB”导入
  • 那么如果您按照错误中的说明进行操作会发生什么? For more information, run 'Import-Module CosmosDB'

标签: linux powershell azure-cosmosdb


【解决方案1】:

能否请您检查一下 Powershell Core 中是否安装了 CosmosDB 模块? 如果没有,请使用以下命令安装它。

Install-Module -Name CosmosDB

如果您已经安装了它,请运行以下命令来检查 cmdlet 是否可用

get-help New-CosmosDbDocument

如果您没有上述 cmdlet,请更新您的 Powershell 核心模块

更新模块 CosmosDb

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-07
    • 2019-08-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-30
    相关资源
    最近更新 更多