Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell AzureRmApiManagementContext:在cmdlet中用作参数时发生FormatException_Powershell_Azure_Azure Powershell_Azure Api Management - Fatal编程技术网

Powershell AzureRmApiManagementContext:在cmdlet中用作参数时发生FormatException

Powershell AzureRmApiManagementContext:在cmdlet中用作参数时发生FormatException,powershell,azure,azure-powershell,azure-api-management,Powershell,Azure,Azure Powershell,Azure Api Management,我正在尝试在AzureRM.apimagement模块中使用一些Azure Powershell cmdlet。许多cmdlet需要context参数,即PsApiManagementContext对象 遵循以下命令,我已使用New-AzureRmApiManagementContextcmdlet创建了一个上下文: $ApiMgmtContext = New-AzureRmApiManagementContext -ResourceGroupName

我正在尝试在
AzureRM.apimagement
模块中使用一些Azure Powershell cmdlet。许多cmdlet需要
context
参数,即
PsApiManagementContext
对象

遵循以下命令,我已使用
New-AzureRmApiManagementContext
cmdlet创建了一个上下文:

$ApiMgmtContext = New-AzureRmApiManagementContext 
                    -ResourceGroupName "MyResourceGroup" 
                    -ServiceName "MyApimService"
然后,我将上下文作为参数传递给cmdlet:

Get azurermapimanagement用户-上下文$ApiMgmtContext

问题是我得到了一个错误,如下所示:

Get-azurermapimanagement用户:FormatException:另一个参数的格式不正确

我已经使用Fiddler检查了它生成的请求,我可以看到请求的主体是空的,因此上下文对象的创建方式肯定有问题,尽管我基本上是在microsoft文档中复制了该示例。我已使用
Login AzureRmAccount
登录我的Azure订阅,并在尝试创建上下文之前选择了正确的订阅


在创建上下文对象时,我做错了什么?

如果在命令中添加
-ErrorVariable error\u message
?然后,当您从$error\u message打印出一条消息时,您得到了什么吗?是的,我得到了
格式异常:还有一个参数的格式不正确
,与上述相同的消息您可以设置
$DebugPreference=“Continue”
在powershell提示符上,在页面上打开一个问题,并提供cmdline的输出。我想到的一件事是,您的脚本中是否有如上所述的换行符?如果是,您应该在每行末尾添加`字符以正确拆分:
$ApiMgmtContext=New AzureRmApiManagementContext`-ResourceGroupName“MyResourceGroup”`-ServiceName“MyApimService”
@DeclanMcNulty请检查您的Azure powershell版本,我的Azure powershell版本是3.7.0,而且
getazurermapimanagementuser-Context$ApiMgmtContext
工作正常。请运行此命令以检查Azure PowerShell版本
获取模块-ListAvailable-Name Azure-Refresh