export-csv help

Hi Guys,


is there a way to export output from below script into excel, subscription wise ? or diff excels for each subscription ?


$resources = Get-AzureRmResource
foreach($resource in $resources)
    if ($resource.Tags -eq $null)
        echo $resource.Name, $resource.ResourceType

Try something like this:

Get-AzureRmResource | #Return all Resources (if you can filter tags here, it is better)
Where-Object -FilterScript {!($_.Tags)} | #if you can't filter at the command, you can filter with Where-Object, ! or -not NULL, which translates to IS NULL
Select-Object -Property Name, Resource | # Get the properties you care about
Export-CSV -Path C:\AzureResource.csv -NoTypeInformation #Export to a CSV


Install-Module ImportExcel # Install the module from PSGallery
Import-Module ImportExcel # Import the module
Import-Module Az # Import the new Azure PowerShell module 'Az' (https://docs.microsoft.com/en-us/powershell/azure/new-azureps-module-az?view=azps-1.1.0)
Get-AzResource|Where-Object-FilterScript {!($_.Tags)} |Select-Object-Property Name, Resource |Export-Excel
# There are vast variety of options with Export-Excel, please explore. (Get-Help Export-Excel -Full)