Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.25k stars 3.85k forks source link

Add-AzMetricAlertRuleV2 - Issue trying to create memory alert #17105

Closed iBowler1995 closed 2 years ago

iBowler1995 commented 2 years ago

Description

When trying to create a memory alert I get the following error:

Add-AzMetricAlertRuleV2 : Exception type: ErrorResponseException, Message: You can't define a scope that is different from the selected target resource type.

Here is the following code I use:

$Condition = New-AzMetricAlertRuleV2Criteria  -MetricName "Memory\% Committed Bytes In Use" -MetricNamespace "Azure.Vm.Windows.GuestMetrics" -TimeAggregation Average -Operator GreaterThanOrEqual -Threshold 95
$Target = Get-AzVM -Name [ServerName]
$ActionGroup = (Get-AzActionGroup -Name "Jira Ticket Creation for Server Support" -ResourceGroupName [AG RG name])
$AGID = New-AzActionGroup -ActionGroupId $ActionGroup.Id
Add-AzMetricAlertRuleV2 -Name "[ServerName] Memory Utilization Over 95 Percent" -ResourceGroupName $ActionGroup.ResourceGroupName -WindowSize 0:5 -Frequency 0:5 -TargetResourceType "Microsoft.Computer/virtualMachines" -TargetResourceScope $Target.Id -TargetResourceRegion $Target.Location -Condition $Condition -ActionGroup $AGID -Severity 0

The weird thing is, I can set CPU and disk alerts just fine on the same server in the same group. Below is the code I used for CPU:

$Condition = New-AzMetricAlertRuleV2Criteria -MetricName "Percentage CPU" -TimeAggregation Average -Operator GreaterThanOrEqual -Threshold 95
$Target = Get-AzVM -Name [ServerName]
$ActionGroup = (Get-AzActionGroup -Name "Jira Ticket Creation for Server Support" -ResourceGroupName [AG RG Name])
$AGID = New-AzActionGroup -ActionGroupId $ActionGroup.Id
Add-AzMetricAlertRuleV2 -Name "[ServerName] CPU Above 95 Percent" -ResourceGroupName $ActionGroup.ResourceGroupName -WindowSize 0:5 -Frequency 0:5 -TargetResourceType "Microsoft.Compute/virtualMachines" -TargetResourceId "$($Target.Id)" -TargetResourceRegion "$($Target.Location)" -Condition $Condition -ActionGroup $AGID -Severity 0

Do I have something wrong with the memory metric here?

Issue script & Debug output

It's going to take several hours to sanitize this debug output. The only information it gave was the same error I'm getting. If it's really needed, I'll sit down and sanitize but I don't particularly have that time right now

Environment data

Name                           Value
----                           -----
PSVersion                      5.1.19041.1320
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1320
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module versions

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     2.7.1      Az.Accounts                         {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollection, Enable-AzContextA...
Script     2.6.0      Az.Accounts                         {Disable-AzDataCollection, Disable-AzContextAutosave, Enable-AzDataCollection, Enable-AzContextA...
Script     4.22.0     Az.Compute                          {Remove-AzAvailabilitySet, Get-AzAvailabilitySet, New-AzAvailabilitySet, Update-AzAvailabilitySe...
Script     3.0.0      Az.Monitor                          {Get-AzMetricDefinition, Get-AzMetric, Remove-AzLogProfile, Get-AzLogProfile...}
Script     3.0.1      Az.OperationalInsights              {New-AzOperationalInsightsAzureActivityLogDataSource, New-AzOperationalInsightsCustomLogDataSour...
Script     5.2.0      Az.Resources                        {Get-AzProviderOperation, Remove-AzRoleAssignment, Get-AzRoleAssignment, New-AzRoleAssignment...}
Script     5.3.1      Azure                               {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAutomationConnection, R...
Binary     2.0.2.140  AzureAD                             {Add-AzureADApplicationOwner, Get-AzureADApplication, Get-AzureADApplicationExtensionProperty, G...
Script     5.1.6      AzureRM.Insights                    {Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-AzureRmLogProfile, Get-AzureRmLogProfile...
Script     5.8.4      AzureRM.profile                     {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, En...
Script     2.0.0      ConvertForm                         {Convert-Form, Test-PSScript}
Script     2.0.3      ExchangeOnlineManagement            {Get-EXOCasMailbox, Get-EXOMailbox, Get-EXOMailboxFolderPermission, Get-EXOMailboxFolderStatisti...
Script     7.3.0      ImportExcel                         {Add-ConditionalFormatting, Add-ExcelChart, Add-ExcelDataValidationRule, Add-ExcelName...}
Script     1.9.2      Microsoft.Graph.Applications        {Add-MgApplicationKey, Add-MgApplicationPassword, Add-MgServicePrincipalKey, Add-MgServicePrinci...
Script     1.9.2      Microsoft.Graph.Authentication      {Connect-MgGraph, Disconnect-MgGraph, Get-MgContext, Get-MgProfile...}
Script     1.9.2      Microsoft.Graph.Bookings            {Get-MgBookingBusiness, Get-MgBookingBusinessAppointment, Get-MgBookingBusinessCalendarView, Get...
Script     1.9.2      Microsoft.Graph.Calendar            {Get-MgGroupCalendar, Get-MgGroupCalendarMultiValueExtendedProperty, Get-MgGroupCalendarPermissi...
Script     1.9.2      Microsoft.Graph.ChangeNotifications {Get-MgSubscription, New-MgSubscription, Remove-MgSubscription, Update-MgSubscription}
Script     1.9.2      Microsoft.Graph.CloudCommunications {Clear-MgCommunicationPresence, Clear-MgCommunicationPresenceUserPreferredPresence, Get-MgCommun...
Script     1.9.2      Microsoft.Graph.Compliance          {Add-MgComplianceEdiscoveryCaseReviewSetQueryTag, Add-MgComplianceEdiscoveryCaseReviewSetToRevie...
Script     1.9.2      Microsoft.Graph.CrossDeviceExper... {Get-MgUserActivity, Get-MgUserActivityHistoryItem, Get-MgUserActivityHistoryItemActivity, Get-M...
Script     1.9.2      Microsoft.Graph.DeviceManagement    {Get-MgDeviceManagement, Get-MgDeviceManagementAdvancedThreatProtectionOnboardingStateSummary, G...
Script     1.9.2      Microsoft.Graph.DeviceManagement... {Add-MgDeviceManagementGroupPolicyUploadedDefinitionFileLanguageFile, Approve-MgDeviceManagement...
Script     1.9.2      Microsoft.Graph.DeviceManagement... {Get-MgDeviceManagementApplePushNotificationCertificate, Get-MgDeviceManagementAuditEvent, Get-M...
Script     1.9.2      Microsoft.Graph.DeviceManagement... {Get-MgDeviceManagementAndroid, Get-MgDeviceManagementAndroidDeviceOwnerEnrollmentProfile, Get-M...
Script     1.9.2      Microsoft.Graph.DeviceManagement... {Compare-MgDeviceManagementIntent, Compare-MgDeviceManagementTemplate, Compare-MgDeviceManagemen...
Script     1.9.2      Microsoft.Graph.Devices.CloudPrint  {Get-MgPrint, Get-MgPrintConnector, Get-MgPrintOperation, Get-MgPrintPrinter...}
Script     1.9.2      Microsoft.Graph.Devices.Corporat... {Clear-MgDeviceAppMgtWindowInformationProtectionDeviceRegistration, Get-MgDeviceAppMgt, Get-MgDe...
Script     1.9.2      Microsoft.Graph.DirectoryObjects    {Confirm-MgDirectoryObjectMemberGroup, Confirm-MgDirectoryObjectMemberObject, Get-MgDirectoryObj...
Script     1.9.2      Microsoft.Graph.Education           {Get-MgEducationClass, Get-MgEducationClassAssignment, Get-MgEducationClassAssignmentCategory, G...
Script     1.9.2      Microsoft.Graph.Files               {Add-MgDriveListContentTypeBaseTypeCopy, Add-MgDriveListContentTypeBaseTypeCopyFromContentTypeHu...
Script     1.9.2      Microsoft.Graph.Financials          {Get-MgFinancial, Get-MgFinancialCompany, Get-MgFinancialCompanyAccount, Get-MgFinancialCompanyA...
Script     1.9.2      Microsoft.Graph.Groups              {Add-MgGroupFavorite, Add-MgGroupToLifecyclePolicy, Confirm-MgGroupGrantedPermission, Confirm-Mg...
Script     1.9.2      Microsoft.Graph.Identity.Directo... {Complete-MgDirectoryImpactedResource, Complete-MgDirectoryRecommendation, Complete-MgDirectoryR...
Script     1.9.2      Microsoft.Graph.Identity.Governance {Add-MgAccessReviewDecision, Add-MgIdentityGovernanceAccessReviewDecisionInstanceDecision, Get-M...
Script     1.9.2      Microsoft.Graph.Identity.SignIns    {Confirm-MgInformationProtectionSignature, Confirm-MgRiskyUserCompromised, Get-MgDataPolicyOpera...
Binary     6.1907.1.0 Microsoft.Graph.Intune              {New-AccessActionObject, New-ActivityHistoryItemObject, New-AlertHistoryStateObject, New-AlertOb...
Script     1.9.2      Microsoft.Graph.Mail                {Get-MgUserInferenceClassification, Get-MgUserInferenceClassificationOverride, Get-MgUserMailFol...
Script     1.9.2      Microsoft.Graph.Notes               {Get-MgGroupOnenoteNotebook, Get-MgGroupOnenoteNotebookSection, Get-MgGroupOnenoteNotebookSectio...
Script     1.9.2      Microsoft.Graph.People              {Get-MgUserActivityStatistics, Get-MgUserLastSharedMethodInsight, Get-MgUserPerson, Get-MgUserPr...
Script     1.9.2      Microsoft.Graph.PersonalContacts    {Get-MgUserContact, Get-MgUserContactExtension, Get-MgUserContactFolder, Get-MgUserContactFolder...
Script     1.9.2      Microsoft.Graph.Planner             {Get-MgGroupPlanner, Get-MgGroupPlannerPlan, Get-MgGroupPlannerPlanBucket, Get-MgGroupPlannerPla...
Script     1.9.2      Microsoft.Graph.Reports             {Get-MgAuditLogDirectoryAudit, Get-MgAuditLogDirectoryProvisioning, Get-MgAuditLogProvisioning, ...
Script     1.9.2      Microsoft.Graph.SchemaExtensions    {Get-MgSchemaExtension, New-MgSchemaExtension, Remove-MgSchemaExtension, Update-MgSchemaExtension}
Script     1.9.2      Microsoft.Graph.Search              {Get-MgExternal, Get-MgExternalConnection, Get-MgSearchAcronym, Get-MgSearchBookmark...}
Script     1.9.2      Microsoft.Graph.Security            {Get-MgSecurityAction, Get-MgSecurityAlert, Get-MgSecurityAttackSimulation, Get-MgSecurityCloudA...
Script     1.9.2      Microsoft.Graph.Sites               {Add-MgSiteContentTypeBaseTypeCopy, Add-MgSiteContentTypeBaseTypeCopyFromContentTypeHub, Add-MgS...
Script     1.9.2      Microsoft.Graph.Teams               {Add-MgChatMember, Add-MgTeamChannelMember, Add-MgTeamMember, Add-MgTeamPrimaryChannelMember...}
Script     1.9.2      Microsoft.Graph.Users               {Get-MgUser, Get-MgUserCreatedObject, Get-MgUserCreatedObjectByRef, Get-MgUserDirectReport...}
Script     1.9.2      Microsoft.Graph.Users.Actions       {Add-MgUserInsightSharedLastSharedMethodMicrosoftGraphWorkbookRange, Add-MgUserInsightSharedLast...
Script     1.9.2      Microsoft.Graph.Users.Functions     {Export-MgUserDeviceAndAppManagementData, Find-MgUserRoom, Find-MgUserRoomList, Get-MgUserCalend...
Script     1.9.2      Microsoft.Graph.WindowsUpdates      {Add-MgWindowsUpdatesDeploymentAudienceMember, Add-MgWindowsUpdatesDeploymentAudienceMemberById,...
Script     1.0.1      Microsoft.PowerShell.Operation.V... {Get-OperationValidation, Invoke-OperationValidation}
Script     4.37.0.0   MSAL.PS                             {Add-MsalClientApplication, Clear-MsalTokenCache, Enable-MsalTokenCacheOnDisk, Get-MsalAccount...}
Script     2.5.0      MSGraphFunctions
Manifest   1.1.183.57 MSOnline                            {Get-MsolDevice, Remove-MsolDevice, Enable-MsolDevice, Disable-MsolDevice...}
Script     1.3.3      NuGet
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     3.4.0      Pester                              {Describe, Context, It, Should...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.0.10     ps2exe                              {Invoke-PS2EXE, ps2exe, ps2exe.ps1, Win-PS2EXE...}
Script     1.6.205    PSFramework                         {ConvertTo-PSFHashtable, Invoke-PSFCallback, Invoke-PSFProtectedCommand, Remove-PSFNull...}
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Set-PSReadLineKeyHandler, Remove-PSReadLineKeyHandler, Get-PSReadLine...

    Directory: C:\Windows\system32\WindowsPowerShell\v1.0\Modules

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   1.0.0.0    AppBackgroundTask                   {Disable-AppBackgroundTaskDiagnosticLog, Enable-AppBackgroundTaskDiagnosticLog, Set-AppBackgroun...
Manifest   2.0.0.0    AppLocker                           {Get-AppLockerFileInformation, Get-AppLockerPolicy, New-AppLockerPolicy, Set-AppLockerPolicy...}
Manifest   1.0.0.0    AppvClient                          {Add-AppvClientConnectionGroup, Add-AppvClientPackage, Add-AppvPublishingServer, Disable-Appv...}
Manifest   2.0.1.0    Appx                                {Add-AppxPackage, Get-AppxPackage, Get-AppxPackageManifest, Remove-AppxPackage...}
Script     1.0.0.0    AssignedAccess                      {Clear-AssignedAccess, Get-AssignedAccess, Set-AssignedAccess}
Manifest   1.0.0.0    BitLocker                           {Unlock-BitLocker, Suspend-BitLocker, Resume-BitLocker, Remove-BitLockerKeyProtector...}
Manifest   2.0.0.0    BitsTransfer                        {Add-BitsFile, Complete-BitsTransfer, Get-BitsTransfer, Remove-BitsTransfer...}
Manifest   1.0.0.0    BranchCache                         {Add-BCDataCacheExtension, Clear-BCCache, Disable-BC, Disable-BCDowngrading...}
Manifest   1.0.0.0    CimCmdlets                          {Get-CimAssociatedInstance, Get-CimClass, Get-CimInstance, Get-CimSession...}
Manifest   1.0        ConfigCI                            {Get-SystemDriver, New-CIPolicyRule, New-CIPolicy, Get-CIPolicy...}
Manifest   1.0        Defender                            {Get-MpPreference, Set-MpPreference, Add-MpPreference, Remove-MpPreference...}
Manifest   1.0.2.0    DeliveryOptimization                {Delete-DeliveryOptimizationCache, Set-DeliveryOptimizationStatus, Get-DeliveryOptimizationLog, ...
Manifest   1.0.0.0    DirectAccessClientComponents        {Disable-DAManualEntryPointSelection, Enable-DAManualEntryPointSelection, Get-DAClientExperience...
Script     3.0        Dism                                {Add-AppxProvisionedPackage, Add-WindowsDriver, Add-WindowsCapability, Add-WindowsImage...}
Manifest   1.0.0.0    DnsClient                           {Resolve-DnsName, Clear-DnsClientCache, Get-DnsClient, Get-DnsClientCache...}
Manifest   1.0.0.0    EventTracingManagement              {Start-EtwTraceSession, New-EtwTraceSession, Get-EtwTraceSession, Update-EtwTraceSession...}
Script     1.1.0.0    IISAdministration                   {Get-IISAppPool, Start-IISCommitDelay, Stop-IISCommitDelay, Get-IISSite...}
Manifest   2.0.0.0    International                       {Get-WinDefaultInputMethodOverride, Set-WinDefaultInputMethodOverride, Get-WinHomeLocation, Set-...
Manifest   1.0.0.0    iSCSI                               {Get-IscsiTargetPortal, New-IscsiTargetPortal, Remove-IscsiTargetPortal, Update-IscsiTargetPorta...
Script     1.0.0.0    ISE                                 {New-IseSnippet, Import-IseSnippet, Get-IseSnippet}
Manifest   1.0.0.0    Kds                                 {Add-KdsRootKey, Get-KdsRootKey, Test-KdsRootKey, Set-KdsConfiguration...}
Manifest   1.0.1.0    Microsoft.PowerShell.Archive        {Compress-Archive, Expand-Archive}
Manifest   3.0.0.0    Microsoft.PowerShell.Diagnostics    {Get-WinEvent, Get-Counter, Import-Counter, Export-Counter...}
Manifest   3.0.0.0    Microsoft.PowerShell.Host           {Start-Transcript, Stop-Transcript}
Manifest   1.0.0.0    Microsoft.PowerShell.LocalAccounts  {Add-LocalGroupMember, Disable-LocalUser, Enable-LocalUser, Get-LocalGroup...}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Script     1.0        Microsoft.PowerShell.ODataUtils     Export-ODataEndpointProxy
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {Get-Acl, Set-Acl, Get-PfxCertificate, Get-Credential...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Format-List, Format-Custom, Format-Table, Format-Wide...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Disable-WSManCredSSP, Enable-WSManCredSSP, Get-WSManCredSSP, Set-WSManQuickConfig...}
Manifest   1.0        MMAgent                             {Disable-MMAgent, Enable-MMAgent, Set-MMAgent, Get-MMAgent...}
Manifest   1.0.0.0    MsDtc                               {New-DtcDiagnosticTransaction, Complete-DtcDiagnosticTransaction, Join-DtcDiagnosticResourceMana...
Manifest   2.0.0.0    NetAdapter                          {Disable-NetAdapter, Disable-NetAdapterBinding, Disable-NetAdapterChecksumOffload, Disable-NetAd...
Manifest   1.0.0.0    NetConnection                       {Get-NetConnectionProfile, Set-NetConnectionProfile}
Manifest   1.0.0.0    NetEventPacketCapture               {New-NetEventSession, Remove-NetEventSession, Get-NetEventSession, Set-NetEventSession...}
Manifest   2.0.0.0    NetLbfo                             {Add-NetLbfoTeamMember, Add-NetLbfoTeamNic, Get-NetLbfoTeam, Get-NetLbfoTeamMember...}
Manifest   1.0.0.0    NetNat                              {Get-NetNat, Get-NetNatExternalAddress, Get-NetNatStaticMapping, Get-NetNatSession...}
Manifest   2.0.0.0    NetQos                              {Get-NetQosPolicy, Set-NetQosPolicy, Remove-NetQosPolicy, New-NetQosPolicy}
Manifest   2.0.0.0    NetSecurity                         {Get-DAPolicyChange, New-NetIPsecAuthProposal, New-NetIPsecMainModeCryptoProposal, New-NetIPsecQ...
Manifest   1.0.0.0    NetSwitchTeam                       {New-NetSwitchTeam, Remove-NetSwitchTeam, Get-NetSwitchTeam, Rename-NetSwitchTeam...}
Manifest   1.0.0.0    NetTCPIP                            {Get-NetIPAddress, Get-NetIPInterface, Get-NetIPv4Protocol, Get-NetIPv6Protocol...}
Manifest   1.0.0.0    NetworkConnectivityStatus           {Get-DAConnectionStatus, Get-NCSIPolicyConfiguration, Reset-NCSIPolicyConfiguration, Set-NCSIPol...
Manifest   1.0.0.0    NetworkSwitchManager                {Disable-NetworkSwitchEthernetPort, Enable-NetworkSwitchEthernetPort, Get-NetworkSwitchEthernetP...
Manifest   1.0.0.0    NetworkTransition                   {Add-NetIPHttpsCertBinding, Disable-NetDnsTransitionConfiguration, Disable-NetIPHttpsProfile, Di...
Manifest   1.0.0.0    PcsvDevice                          {Get-PcsvDevice, Start-PcsvDevice, Stop-PcsvDevice, Restart-PcsvDevice...}
Binary     1.0.0.0    PersistentMemory                    {Get-PmemDisk, Get-PmemPhysicalDevice, Get-PmemUnusedRegion, New-PmemDisk...}
Manifest   1.0.0.0    PKI                                 {Add-CertificateEnrollmentPolicyServer, Export-Certificate, Export-PfxCertificate, Get-Certifica...
Manifest   1.0.0.0    PnpDevice                           {Get-PnpDevice, Get-PnpDeviceProperty, Enable-PnpDevice, Disable-PnpDevice}
Manifest   1.1        PrintManagement                     {Add-Printer, Add-PrinterDriver, Add-PrinterPort, Get-PrintConfiguration...}
Binary     1.0.12     ProcessMitigations                  {Get-ProcessMitigation, Set-ProcessMitigation, ConvertTo-ProcessMitigationPolicy}
Script     3.0        Provisioning                        {Install-ProvisioningPackage, Export-ProvisioningPackage, Install-TrustedProvisioningCertificate...
Manifest   1.1        PSDesiredStateConfiguration         {Set-DscLocalConfigurationManager, Start-DscConfiguration, Test-DscConfiguration, Publish-DscCon...
Script     1.0.0.0    PSDiagnostics                       {Disable-PSTrace, Disable-PSWSManCombinedTrace, Disable-WSManTrace, Enable-PSTrace...}
Binary     1.1.0.0    PSScheduledJob                      {New-JobTrigger, Add-JobTrigger, Remove-JobTrigger, Get-JobTrigger...}
Manifest   2.0.0.0    PSWorkflow                          {New-PSWorkflowExecutionOption, New-PSWorkflowSession, nwsn}
Manifest   1.0.0.0    PSWorkflowUtility                   Invoke-AsWorkflow
Manifest   1.0.0.0    ScheduledTasks                      {Get-ScheduledTask, Set-ScheduledTask, Register-ScheduledTask, Unregister-ScheduledTask...}
Manifest   2.0.0.0    SecureBoot                          {Confirm-SecureBootUEFI, Set-SecureBootUEFI, Get-SecureBootUEFI, Format-SecureBootUEFI...}
Manifest   2.0.0.0    SmbShare                            {Get-SmbShare, Remove-SmbShare, Set-SmbShare, Block-SmbShareAccess...}
Manifest   2.0.0.0    SmbWitness                          {Get-SmbWitnessClient, Move-SmbWitnessClient, gsmbw, msmbw...}
Manifest   1.0.0.2    StartLayout                         {Export-StartLayout, Import-StartLayout, Export-StartLayoutEdgeAssets, Get-StartApps}
Manifest   2.0.0.0    Storage                             {Add-InitiatorIdToMaskingSet, Add-PartitionAccessPath, Add-PhysicalDisk, Add-StorageFaultDomain...}
Manifest   1.0.0.0    StorageBusCache                     {Clear-StorageBusDisk, Disable-StorageBusCache, Disable-StorageBusDisk, Enable-StorageBusCache...}
Manifest   2.0.0.0    TLS                                 {New-TlsSessionTicketKey, Enable-TlsSessionTicketKey, Disable-TlsSessionTicketKey, Export-TlsSes...
Manifest   1.0.0.0    TroubleshootingPack                 {Get-TroubleshootingPack, Invoke-TroubleshootingPack}
Manifest   2.0.0.0    TrustedPlatformModule               {Get-Tpm, Initialize-Tpm, Clear-Tpm, Unblock-Tpm...}
Binary     2.1.639.0  UEV                                 {Clear-UevConfiguration, Clear-UevAppxPackage, Restore-UevBackup, Set-UevTemplateProfile...}
Manifest   2.0.0.0    VpnClient                           {Add-VpnConnection, Set-VpnConnection, Remove-VpnConnection, Get-VpnConnection...}
Manifest   1.0.0.0    Wdac                                {Get-OdbcDriver, Set-OdbcDriver, Get-OdbcDsn, Add-OdbcDsn...}
Manifest   1.0.0.0    WebAdministration                   {Start-WebCommitDelay, Stop-WebCommitDelay, Get-WebConfigurationLock, Remove-WebConfigurationLoc...
Manifest   2.0.0.0    Whea                                {Get-WheaMemoryPolicy, Set-WheaMemoryPolicy}
Manifest   1.0.0.0    WindowsDeveloperLicense             {Get-WindowsDeveloperLicense, Unregister-WindowsDeveloperLicense, Show-WindowsDeveloperLicenseRe...
Script     1.0        WindowsErrorReporting               {Enable-WindowsErrorReporting, Disable-WindowsErrorReporting, Get-WindowsErrorReporting}
Manifest   1.0.0.0    WindowsSearch                       {Get-WindowsSearchSetting, Set-WindowsSearchSetting}
Manifest   1.0.0.0    WindowsUpdate                       Get-WindowsUpdateLog

Error output

WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use
`Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other
information on breaking changes in Azure PowerShell.

   HistoryId: 5

Message        : Exception type: ErrorResponseException, Message: You can't define a scope that is different from the
                 selected target resource type. Activity ID: 5fca82a6-8b32-43bc-89b0-e06b636ca487., Code: BadRequest,
                 Status code:BadRequest, Reason phrase: BadRequest
StackTrace     :    at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet()
                    at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord()
Exception      : System.Management.Automation.PSInvalidOperationException
InvocationInfo : {Add-AzMetricAlertRuleV2}
Line           : Add-AzMetricAlertRuleV2 -Name " Memory Utilization Over 95 Percent" -ResourceGroupName
                 $ActionGroup.ResourceGroupName -WindowSize 0:5 -Frequency 0:5 -TargetResourceType
                 "Microsoft.Computer/virtualMachines" -TargetResourceScope "$($Target.Id)" -TargetResourceRegion
                 "$($Target.Location)" -Condition $Condition -ActionGroup $AGID -Severity 0
Position       : At line:5 char:1
                 + Add-AzMetricAlertRuleV2 -Name " Memory Utilization Over 95  ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 5

Message        : Operation returned an invalid status code 'BadRequest'
StackTrace     :    at Microsoft.Azure.Management.Monitor.MetricAlertsOperations.<CreateOrUpdateWithHttpMessagesAsync>d
                 __8.MoveNext()
                 --- End of stack trace from previous location where exception was thrown ---
                    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
                    at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
                    at Microsoft.Azure.Management.Monitor.MetricAlertsOperationsExtensions.<CreateOrUpdateAsync>d__7.Mo
                 veNext()
Exception      : Microsoft.Azure.Management.Monitor.Models.ErrorResponseException
InvocationInfo : {Add-AzMetricAlertRuleV2}
Line           : Add-AzMetricAlertRuleV2 -Name " Memory Utilization Over 95 Percent" -ResourceGroupName
                 $ActionGroup.ResourceGroupName -WindowSize 0:5 -Frequency 0:5 -TargetResourceType
                 "Microsoft.Computer/virtualMachines" -TargetResourceScope "$($Target.Id)" -TargetResourceRegion
                 "$($Target.Location)" -Condition $Condition -ActionGroup $AGID -Severity 0
Position       : At line:5 char:1
                 + Add-AzMetricAlertRuleV2 -Name " Memory Utilization Over 95  ...
                 + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HistoryId      : 5

The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
iBowler1995 commented 2 years ago

I'm so dumb. I had a type. Microsoft.Computer is what I used instead of Microsoft.Compute.