An Azure service that provides secure managed services and access control for partners and customers.
Hello Marianda Potgieter,
Thank you for reaching out to the Microsoft Q&A forum.
It sounds like you're looking to automate the process of collecting performance and configuration data from multiple customer tenants using PowerShell and Azure Lighthouse. Here’s a general approach you can take to achieve this:
Step-by-Step Process
Set Up PowerShell Module: First, ensure you have the Azure PowerShell module installed. You can install it using:
Install-Module -Name Az -AllowClobber -Scope CurrentUser
Authenticate with Azure: When using Azure Lighthouse, you will authenticate in your managing tenant and connect to the customer tenants without needing to log in each time.
Connect-AzAccount
List of Customer Tenants: Prepare a list of your customer tenant IDs. You can store these in an array for iteration. For example:
$customerTenants = @("tenantID1", "tenantID2", "tenantID3")
Loop Through Each Tenant: Use a loop to go through each tenant and run your desired queries. Here’s a basic example to collect CPU, Memory, and Disk information:
foreach ($tenant in $customerTenants) {
# Switch to the customer tenant
Set-AzContext -TenantId $tenant
# Get monitoring data (replace with your specific commands)
# Example: Get CPU and Memory Usage
$vmMetrics = Get-AzVM | ForEach-Object {
Get-AzVMSize -ResourceGroupName $_.ResourceGroupName -VMName $_.Name
}
# Output the metrics or store them as needed
$vmMetrics | Export-Csv -Path "monitoringData_$($tenant).csv"
}
Additional Data Collection: For NSG rules or backup information, you can utilize other relevant cmdlets:
NSG Rules:
Get-AzNetworkSecurityGroup
Backup Status: Depending on your setup, you might need to use Azure Backup cmdlets.
Additional Considerations
Error Handling: Implement error handling within your loop to account for potential issues when querying each tenant.
Optimizing Performance: If you have a large number of tenants, consider running queries asynchronously.
Reporting: After data collection, you can format the output as needed using ConvertTo-Html or similar commands to generate reports.
Useful Documentation Links
- Azure PowerShell Documentation
- Automate Management Tasks with Azure PowerShell
- Azure Lighthouse Overview
Let us know if you have further questions?