need to compare the powershell script output with input csv file and get output

Welcome Forums General PowerShell Q&A need to compare the powershell script output with input csv file and get output

Viewing 3 reply threads
  • Author
    Posts
    • #243926
      Participant
      Topics: 1
      Replies: 1
      Points: -6
      Rank: Member

      Hi Friends

      I would like to compare the power shell script output with import csv file and get the output as pass for matched values and fail for non matched values

      Thanks in advance.

      • This topic was modified 2 months ago by kvprasoon. Reason: code formatting
    • #244004
      Participant
      Topics: 7
      Replies: 2458
      Points: 6,439
      Helping Hand
      Rank: Community MVP

      Bhanu, welcome to Powershell.org. Please take a moment and read the very first post on top of the list of this forum: Read Me Before Posting! You’ll be Glad You Did!.

      That’s a lot of code and just with a quick overlook I can tell that you have a lot of redundant and unnessecary convoluted code and you don’t tell us what is not working or where you have some problems.

      For example: Instead of calling Get-VMHost 12 times inside your foreach loop you call it once, save the resulting objects to a variable and use this variable 12 times. 😉

    • #244016
      Participant
      Topics: 1
      Replies: 1
      Points: -6
      Rank: Member

      Hi Olaf

      Thanks for the reply

      when im trying to compare the script output(csv) with input csv file , output is showing as below in csv

      SideIndicator Length
      => 37
      <= 39

      Also can we compare the powershell output with input csv file, if yes please share the sample code

      thanks in advance.

    • #244094
      Participant
      Topics: 15
      Replies: 1776
      Points: 3,218
      Helping Hand
      Rank: Community Hero

      This logic could be improved as you adding -IncludeEqual and then you filter it out Where { $_.SideIndicator -ne “==” }, you just remove -IncludeEqual:

      It appears you are trying to compare a row of data rather than a property. Look at example 5 in the Compare-Object documentation where they are comparing multiple properties in an object.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.