Mind blown $Obj saves to CSV drops domain, when using F8 it saves!

Welcome Forums General PowerShell Q&A Mind blown $Obj saves to CSV drops domain, when using F8 it saves!

This topic contains 0 replies, has 1 voice, and was last updated by  Aldo de Beunje 2 months, 1 week ago.

  • Author
    Posts
  • #164713

    Participant
    Topics: 2
    Replies: 0
    Points: 25
    Rank: Member

    My mind is blown i can not get this working.

    I am creating an Object

     $obj = [pscustomobject]@{ Domain = $domain; 
    IPAdress = $ipaddress; 
    PacketsLostPercentage = $packetslossed_percentage; 
    Average=$average}

    It is filled with the correct information. Selecting the $Obj and hitting F8 in ISE shows this:

    Domain                                  IPAdress         PacketsLostPercentage    Average
    tenant.sharepoint.com      13.107.136.9      0                                         5.14

    It then gets writting to a csv file with a function:

    write-to-csv $obj

    When i test it there the information is still in the Object. All of type String.

    In my function i do this:

    $Obj | Export-Csv -Path $working_path\$csvFileName -Append -NoTypeInformation

    And everything gets writtin corectly to the csv file exept the domain tenant.sharepoint.com

    And now for the kicker: If i select the line above and hit F8, all the information is still in the object and it gets writtin to the file, including the domain! I am at a loss. Please help.

     

    Thanks

     

     

     

     

     

You must be logged in to reply to this topic.