Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

doesn't contain a method named 'op_Addition'.

$
0
0

 

 

 

 

 

 

 

 

 

 

 

 

 

Hi,

I look for a solution to add\delete PSObjects from an array.

It looks like if their only one item remains in the array it is not possible to add a new object.

This example get an error with adding a new object.

With this line it is working

$X=$AllQ | Where-Object {$_.Queue -neQ1"}

 

$AllQ

 

 

= @()

For ($i=0;$i-lt 10;$i++) {

 

 

 

$X=New-ObjectPSObject-Property$QProps

 

 

 

$X.Queue="Q$i"

 

 

 

$X.Depth= $i

 

 

 

$AllQ+=$X

}

 

$X

 

 

= @()

$X

 

 

=$AllQ | Where-Object {$_.Queue -eqQ1"}

 

 

 

 $A=New-ObjectPSObject-Property$QProps

 

 

 

 $A.Queue="XX"

 

 

 

 $A.Depth0

 

 

 

 $X+=$A

 

exit

 

Method invocation failed because [System.Management.Automation.PSObject] doesn't contain a method named 'op_Addition'.

At C:\Users\spbpho\AppData\Local\Temp\2\f5b794ec-9548-4d85-b162-e085df99a264.ps1:17 char:8

+ $X += <<<< $A

+ CategoryInfo : InvalidOperation: (op_Addition:String) [], RuntimeException

+ FullyQualifiedErrorId : MethodNotFound

 

 

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles