Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🪲 Bug Report - 1_wara_collector.ps1 failed with "Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'." error #574

Open
yuriwoof opened this issue Dec 16, 2024 · 4 comments
Assignees
Labels
Bug 🐞 Something isn't working

Comments

@yuriwoof
Copy link

Describe the bug

I got below error at collection information.

PS C:\Users\yuohno\Documents\WARA> .\1_wara_collector.ps1 -TenantID "(My Tenant ID" -SubscriptionIds "/subscriptions/(My Subscription ID)"

...

Selecting In-Scope Resources..
Ordering Impacted Resources..
Filtering Impacted Resources..
Filtering Advisor Resources..
Filtering Out of Scope Resources..
InvalidOperation: C:\Users\yuohno\Documents\WARA\1_wara_collector.ps1:1637
Line |
1637 |        $Script:Advisories += $return
     |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named
     | 'op_Addition'.

---------------------------------------------------------------------
Execution Complete. Total Runtime was: 1.63 Minutes
Result File: C:\Users\yuohno\Documents\WARA\WARA-File-2024-12-16-10-31.json
---------------------------------------------------------------------

To Reproduce

PS C:\Users\yuohno\Documents\WARA> invoke-webrequest https://aka.ms/aprl/tools/1 -out 1_wara_collector.ps1
PS C:\Users\yuohno\Documents\WARA> .\1_wara_collector.ps1 -TenantID "(My Tenant ID" -SubscriptionIds "/subscriptions/(My Subscription ID)"

Expected behaviour

Script finish without error.

Screenshots 📷

Image

Additional context

  • Environment

    • PowerShell Version : 7.4.6
    • Azure PowerShell Version: 12.3.0
    • Have Owner role for subscription
  • Reproduction in Azure Cloud Shell

    • Confirmed that performed ARG query get Advisor result successfully

Image

  • Adding $Script:advisories=@() avoid this error.
      if(![String]::IsNullOrEmpty($return)){

          $tmp = [PSCustomObject]@{
          'Resource Type'              = 'microsoft.subscription/subscriptions'
          'Number of Resources'        =  $return.Count
          'Available in APRL/ADVISOR?' = 'Yes'
          'Assessment Owner'           = ''
          'Status'                     = ''
          'Notes'                      = ''
        }

        $Script:AllResourceTypesOrdered += $tmp
      }


      $Script:advisories=@()

      $Script:Advisories += $return
  }
@microsoft-github-policy-service microsoft-github-policy-service bot added the Bug 🐞 Something isn't working label Dec 16, 2024
@kpoineal
Copy link
Contributor

@yuriwoof Thanks for the bug report. This happens when there is one item returned. We have a different way to fix this and will get it pushed out soon.

The fix you have in your code will clear the advisories array, I would check your advisories and make sure everything is showing up.

@kpoineal
Copy link
Contributor

@yuriwoof I am unable to reproduce this error even with one item returned. Can you reach out to me internally and we can investigate this further?

Thank you!

@yuriwoof
Copy link
Author

@kpoineal sure! I'll contact you internally.

@tksh164
Copy link
Member

tksh164 commented Dec 20, 2024

I was handover from @kpoineal and talked with @yuriwoof. I started an investigation into this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🐞 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants