output wrong way

Welcome Forums General PowerShell Q&A output wrong way

Viewing 2 reply threads
  • Author
    Posts
    • #205065
      Participant
      Topics: 7
      Replies: 8
      Points: 139
      Rank: Participant

      I created csv file by script. I like to output full data and filtered data separating by “+”

      However, I always get “+” on the top and full data and filtered data together.

      import-csv .\tempdata.csv
      
      write-host '+++++++++' -Backgroundcolor Yellow
      
      import-csv .\tempdata.csv |where {$_.hostname -notmatch "2xx"}

      Here is my output

      +++++++++++++++++++++++
      
      10.10.101.111   K-2xx1234
      
      10.10.101.123  K-3wxy123
      
      10.10.101.31    K-1wxy234
      
      10.10.101.123  K-3wxy123
      
      10.10.101.31    K-1wxy234

      One more question: I learn from here but I forgot the correct syntax

      write-output "The folder name is $1 and file name is $2" -f $a, $b

      Can someone remind me the correct syntax?

      Thanks in advance

      • This topic was modified 3 months, 1 week ago by grokkit. Reason: please format your code as per the forum posting instructions
    • #205068
      Senior Moderator
      Topics: 8
      Replies: 1215
      Points: 4,335
      Helping Hand
      Rank: Community Hero

      This will be a simple one, but before showing up the solution can you explain a little bit on how you expect the above code to work for the output you want. Based on that it’ll be easy to guide and tell you where the mistake has happened.

      You can post the expected output as well…

    • #205101
      Participant
      Topics: 7
      Replies: 8
      Points: 139
      Rank: Participant

      my expected output:

      10.10.101.111   K-2xx1234

      10.10.101.123  K-3wxy123

      10.10.101.31    K-1wxy234

      +++++++++++++++++++++++

      10.10.101.123  K-3wxy123

      10.10.101.31    K-1wxy234

Viewing 2 reply threads
  • The topic ‘output wrong way’ is closed to new replies.