Want to know about innovative and interesting ideas in Azure and automation? Check out my blog: https://manjunathrao.com.
Version 2.0:
I have changed the design of this script. It no longer creates a single Excel sheet. Rather, produces a CSV file for individual services inside individual subscription's folder.
DESCRIPTION: This script will pull the infrastructure details of the Azure subscriptions. Details will be stored under the folder "c:\AzureInventory"If you have multiple subscriptions, a separate folder will be created for individual subscription.CSV files will be created for individual services (Virtual Machines, NSG rules, Storage Account, Virtual Networks, Azure Load Balancers) inside the subscription's directory
function Invoke-GetAzureInventoryFunction{ 
    # Sign into Azure Portal 
    # Fetching subscription list 
    $subscription_list = get-azurermsubscription 
    # Fetch current working directory  
    $working_directory = "c:\AzureInventory" 
    new-item $working_directory -ItemType -Force 
    # Fetching the IaaS inventory list for each subscription 
    foreach($subscription_list_iterator in $subscription_list){ 
        Get-AzureInventory($subscription_list_iterator.id, $subscription_list_iterator.name)