locked
Import-CSV commands adds additional objects that does not exist in the CSV file RRS feed

  • Question

  • Hello,

    While using Import-CSV I am getting additional data that does not exist in the CSV file.

    Example : PSComputerName, RunSpaceID, PSShowComputerName

    How do i exclude this from being captured in a Import-CSV command from a csv file?

    Monday, March 14, 2016 1:40 PM

Answers

  • But then how do i remove it?

    Pipe through select-object.

    And why does that matter?

    That's how it works.


    EDIT: Why are you using Invoke-Command in the first place? Just import the file directly.

    • Edited by Mike Laughlin Monday, March 14, 2016 2:28 PM
    • Proposed as answer by Elaine Jing Wednesday, April 6, 2016 11:31 AM
    • Marked as answer by Elaine Jing Thursday, April 7, 2016 2:53 AM
    Monday, March 14, 2016 2:27 PM

All replies

  • Hello,

    could you post the beginning of your csv file (header and some data rows) and the respective part of your script?

    Best wishes 

    Christoph

    Monday, March 14, 2016 2:04 PM
  • Hi,

    That's not possible. Import-Csv can only import data that exists.

    What's your exact command?


    Monday, March 14, 2016 2:04 PM
  • The header only has ComputerName, username and a list of devices

    Import-csv -path $path
    Monday, March 14, 2016 2:20 PM
  • The header only has ComputerName, username and a list of devices

    Import-csv -path $path

    When i go to the csv file i dont see those items in the columns. Im not really sure how its getting there.

    I am remotely going out to a remote machine to import-csv command.
    Monday, March 14, 2016 2:23 PM
  • I am remotely going out to a remote machine to import-csv command.
    This is why.

    Monday, March 14, 2016 2:23 PM
  • But then how do i remove it?

    And why does that matter?
    Monday, March 14, 2016 2:25 PM
  • But then how do i remove it?

    Pipe through select-object.

    And why does that matter?

    That's how it works.


    EDIT: Why are you using Invoke-Command in the first place? Just import the file directly.

    • Edited by Mike Laughlin Monday, March 14, 2016 2:28 PM
    • Proposed as answer by Elaine Jing Wednesday, April 6, 2016 11:31 AM
    • Marked as answer by Elaine Jing Thursday, April 7, 2016 2:53 AM
    Monday, March 14, 2016 2:27 PM
  • Ok i will try to pipe it to a select-object and give it a try
    Monday, March 14, 2016 2:28 PM