none
Append Row Error RRS feed

  • Question

  • I have 2 PSO as below, when appending it, I got error. Any other way to do that? Thanks

    [DBG]: PS C:\Windows\system32>> $a

    Time   : 10:56:01
    Symbol : HEXO
    Price  : 2.30
    Up%    : 9
    Volume : 2042998
    Notes  : Market Mover: up > 4%
    Bcolor : 128.255.128
    Cno    : 1

    [DBG]: PS C:\Windows\system32>> $b

    Time   : 11:53:01
    Symbol : APHA
    Price  : 5.51
    Up%    : 9.54
    Volume : 2222585
    Notes  : Market Mover: up > 4%
    Bcolor : 128.255.128
    Cno    : 0

    [DBG]: PS C:\Windows\system32>> $a += $b
    Method invocation failed because [System.Management.Automation.PSObject] does not contain a
    method named 'op_Addition'.
    At line:1 char:1
    + $a += $b
    + ~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (op_Addition:String) [], RuntimeException
        + FullyQualifiedErrorId : MethodNotFound

    Tuesday, November 19, 2019 5:04 PM

Answers

  • The collection doe not support that capability. You cannot add two objects together. To create a collection you must use a collection object

    [array]$c += $a
    $c += $b

    Collections and value types support this capability but PsObject and other object types do not unless the capability has been designed into the type.


    \_(ツ)_/

    • Marked as answer by Ian3 Tuesday, November 19, 2019 5:39 PM
    Tuesday, November 19, 2019 5:12 PM
    Moderator

All replies

  • What's the purpose of adding 2 objects?

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Tuesday, November 19, 2019 5:08 PM
  • The collection doe not support that capability. You cannot add two objects together. To create a collection you must use a collection object

    [array]$c += $a
    $c += $b

    Collections and value types support this capability but PsObject and other object types do not unless the capability has been designed into the type.


    \_(ツ)_/

    • Marked as answer by Ian3 Tuesday, November 19, 2019 5:39 PM
    Tuesday, November 19, 2019 5:12 PM
    Moderator