【问题标题】:Microsoft.Azure.IpSecurityRestriction not found in Azure PowerShell script在 Azure PowerShell 脚本中找不到 Microsoft.Azure.IpSecurityRestriction
【发布时间】:2019-03-08 10:26:37
【问题描述】:

我正在尝试运行一些 PowerShell 命令,但我的脚本在以下行中失败:

$ipsr = New-Object Microsoft.Azure.IpSecurityRestriction

错误是:

Cannot find type [Microsoft.Azure.IpSecurityRestriction]: verify that the assembly containing this type is loaded

我正在尝试在 Azure PowerShell 任务中运行这个“内联”,作为我的部署管道的一部分。这是支持还是我需要先导入程序集?

【问题讨论】:

  • 您好,能否告诉我它是否解决了您的问题?
  • 抱歉耽搁了。是的,你的回复解决了我的问题。非常感谢。

标签: azure-powershell


【解决方案1】:

我可以重现您的问题。首先,它应该是Microsoft.Azure.Management.WebSites.Models.IpSecurityRestriction,而不是Microsoft.Azure.IpSecurityRestriction,然后确保你已经安装了Az.Websites powershell 模块,使用下面的命令即可。

Import-Module -Name Az.Websites
New-Object Microsoft.Azure.Management.WebSites.Models.IpSecurityRestriction

另外,其实我们导入模块只是为了Microsoft.Azure.Management.Websites.dll,所以你也可以使用如下命令,检查你的.dll文件的路径。

Add-Type -Path 'C:\Program Files\WindowsPowerShell\Modules\Az.Websites\1.1.0\Microsoft.Azure.Management.Websites.dll'
New-Object Microsoft.Azure.Management.WebSites.Models.IpSecurityRestriction

【讨论】:

    猜你喜欢
    • 2020-09-07
    • 1970-01-01
    • 2018-09-14
    • 2019-04-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-13
    相关资源
    最近更新 更多