troubleshooting Question

powershell error using $networksecuritygroup

Avatar of Kelly Garcia
Kelly GarciaFlag for United Kingdom of Great Britain and Northern Ireland asked on
1 Comment1 Solution62 ViewsLast Modified:

I have the following code in my powershell script

foreach ($ns in $NSGName){

$networksecuritygroup += Get-azNetworkSecurityGroup | Where-Object {$_.Name -eq "$ns"-and $_.Location -eq "$l" }


Open in new window

when i run it, it gives me the following error:

Method invocation failed because [Microsoft.Azure.Commands.Network.Models.PSNetworkSecurityGroup] does not contain a method named 'op_Addition'.
At C:\Users\kellygarcia\Dropbox\IT Training\\Projects\DiagnosticsLogs\Scripts\DiagnosticStream\Final\NSGFlowLogs\NSGFlowLogs_8.ps1:277 char:1
+ $networksecuritygroup += Get-azNetworkSecurityGroup | Where-Object {$ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
    + FullyQualifiedErrorId : MethodNotFound

Open in new window

Join our community to see this answer!
Unlock 1 Answer and 1 Comment.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros