Get WebApplicationMonitoringStatus - PowerShell
Overview
Get-WebApplicationMonitoringStatus retrieves the monitoring status of a specific web application. This command provides information about whether monitoring is currently enabled or disabled, the last time the monitoring configuration was modified, and the monitoring plan assigned to the web application.
Syntax
Get-WebApplicationMonitoringStatus [-Name] <String> [-ResourceGroupName] <String> [-WebsiteName] <String> [<CommonParameters>]
Options/Flags
| Option | Description | Default|
|—|—|—|
| -Name | Name of the web application to get the monitoring status of. | |
| -ResourceGroupName | Name of the resource group containing the web application. | |
| -WebsiteName | Name of the website containing the web application. | |
Examples
Example 1: Get monitoring status of a web application
Get-WebApplicationMonitoringStatus -Name mywebapp -ResourceGroupName myresourcegroup -WebsiteName mywebsite
Example 2: Check if monitoring is enabled
if (Get-WebApplicationMonitoringStatus -Name mywebapp -ResourceGroupName myresourcegroup -WebsiteName mywebsite).MonitoringEnabled) {
Write-Host "Monitoring is enabled"
}
Common Issues
Error: The specified web application does not exist.
- Ensure the web application name is correct and that it exists in the specified resource group and website.
Integration
Example: Disable monitoring for all web applications in a resource group
Get-WebApplications -ResourceGroupName myresourcegroup | ForEach-Object {
Get-WebApplicationMonitoringStatus -Name $_.Name -ResourceGroupName myresourcegroup -WebsiteName $_.WebsiteName | Set-WebApplicationMonitoringStatus -MonitoringEnabled $false
}