【发布时间】:2019-10-17 16:39:13
【问题描述】:
我正在尝试编写 powershell 脚本来获取所有 webapps 和每个 azure web 应用程序的一些属性。下面是我尝试过的脚本,但它给了我Http20Enabled is not valid property 错误。我认为不知何故我使用了错误的范围。
我需要在 CSV 文件的单行中获取该 webapp 的 Webapp 和 SiteConfig 的属性。
Get-AzureRmWebApp | ForEach-Object {
($webapp = $_) | Get-AzureRmWebApp -ResourceGroupName {$webapp.ResourceGroup} -Name {$webapp.Name} | select -ExpandProperty SiteConfig | Select-Object @{
Http20Enabled = $_.Http20Enabled
MinTlsVersion = $_.MinTlsVersion
AlwaysOn = $_.AlwaysOn
Cors = $_.Cors
Owner = {$webapp.Tags.Owner}
Name = {$webapp.Name}
ResourceGroup = {$webapp.ResourceGroup}
HttpsOnly = {$webapp.HttpsOnly}
ClientAffinityEnabled = {$webapp.ClientAffinityEnabled}
}
}| Export-Csv "C:apps1\test.csv"
更新:
试过这个:
Get-AzureRMWebApp | ForEach-Object {
$webapp = Get-AzureRMWebApp -ResourceGroupName $_.ResourceGroup -Name $_.Name
New-Object -TypeName psobject -property @{
Http20Enabled = $webapp.siteconfig.Http20Enabled
MinTlsVersion = $webapp.siteconfig.MinTlsVersion
AlwaysOn = $webapp.siteconfig.AlwaysOn
Cors = $webapp.siteconfig.Cors
Owner = $webapp.Tags.Owner
Name = $webapp.Name
ResourceGroup = $webapp.ResourceGroup
HttpsOnly = $webapp.HttpsOnly
ClientAffinityEnabled = $webapp.ClientAffinityEnabled
}
}
得到错误 -
无法将“System.Object[]”转换为所需的“System.String”类型 通过参数“资源组名称”。不支持指定的方法。
PSVersion 5.1.17763.771
AzureRM 5.7.0
【问题讨论】:
标签: azure-web-app-service azure-powershell azure-app-service-plans