I'm trying to write powershell script which gets all webapps and few properties of each azure web app. Below is the script i tried but it's giving me Http20Enabled
is not valid property error. I think somehow i'm using the wrong scope.
I need to get properties of Webapp
and SiteConfig
of that webapp in a single row in CSV file.
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"
Updated:
Tried this :
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
}
}
Got the error -
Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'ResourceGroupName'. Specified method is not supported.
PSVersion 5.1.17763.771
AzureRM 5.7.0