Historical and Trend Reports in PowerShell

This topic contains 0 replies, has 1 voice, and was last updated by Profile photo of Forums Archives Forums Archives 5 years, 5 months ago.

  • Author
    Posts
  • #5401

    by joharra at 2013-01-04 07:06:53

    I was excited to see the draft of this book, since I am also a fan of ditching Excel for database functions.

    While trying out some of the code in the document and related modules, I ran across some statements that do not work correctly. I am using PowerShell v2, but I do no think that is the cause of the problem.

    In the "Test-Database" function from the "SQLReporting" module, the following line returns an array:
    $TypeName = $object | Get-Member | select-object -ExpandProperty TypeName

    which causes an error with this line:
    $Table = $typename.split('.')[1]
    Error: Method invocation failed because [System.Object[]] doesn't contain a method named 'split'.

    In order to get it to work properly, I had to change the line to:
    $TypeName = ($object | Get-Member | select-object -ExpandProperty TypeName)[0]

    or change this one:
    $Table = $typename[0].split('.')[1]

    Is the behavior different with PowerShell v3?

    by DonJ at 2013-01-08 08:19:48

    Apparently. It's working fine as-is in v3 for me. v3 does have automatic object enumeration, which is probably what you're running into.

You must be logged in to reply to this topic.