I want to export the results of a WebApp to a CSV file, however Export-CSV is only exporting the last object. It seems like something is going wrong on the part of PSCustomObject but I can't figure out why. Any idea's?
$outputForCsv = ""
foreach ($rg in $resourceGroups) {
$rgName = $rg.ResourceGroupName
$webAppsInRg = Get-AzWebApp -ResourceGroupName $rgName
$webAppNamesInRg = $webAppsInRg.Name
foreach($webAppName in $webAppNamesInRg){
$webApp = (Get-AzWebApp -ResourceGroupName $rgName -Name $webAppName)
$tls = $webApp.SiteConfig.MinTlsVersion
$http20Enabled = $webApp.SiteConfig.Http20Enabled
$outputForCsv +=
[PSCustomObject]@{
ResourceGroup = $rg.ResourceGroupName
WebAppName = $webAppName
MinTlsVersion = $tls
Http20Enabled = $http20Enabled
}
}
}
$outputForCsv | Export-Csv "data.csv" -delimiter ";" -NoTypeInformation