none
Matching a server to an owners name in a CSV file RRS feed

  • Question

  • I am able to go through this 1000 line plus CSV file with this foreach loop to find the owner of the server. But I feel there should be a cleaner way. Here is what I have so far

    $sharepoint = Import-Csv "C:\PatchCheck\SharePoint.csv"
    foreach ($i in $sharepoint)
        {
        if ($i.'Server Name' -eq 'ABCARCTPACS01')
            {
            $appowner = $i.'App Owner'
             }
        }
        Write-Host $appowner

    This will work but I feel it is working to hard for what I want to do. I need to match up the 'Server Name' with the 'App Owner' for all 1000+ servers.

    at some point I would like to pull this information from SharePoint where I extracted the CSV file from.

    Thank you in advance for any help you can give. 

    Thursday, April 16, 2015 8:22 PM

Answers

  • 1000+ names in a file are trivial.  YOU wl not notice it if it is not perfect.

    Perhaps a tutorial on looping and code formatting would help:

    Here is the melt down of your guess.  A little study will explain it.

    Import-Csv C:\PatchCheck\SharePoint.csv | where-object{$_.'Server Name' -eq 'ABCARCTPACS01'}

    It is good that you used single quotes.  Few new users know how to do that.


    \_(ツ)_/

    • Marked as answer by Winterwolf71 Friday, April 17, 2015 4:31 PM
    Thursday, April 16, 2015 11:05 PM

All replies

  • 1000+ names in a file are trivial.  YOU wl not notice it if it is not perfect.

    Perhaps a tutorial on looping and code formatting would help:

    Here is the melt down of your guess.  A little study will explain it.

    Import-Csv C:\PatchCheck\SharePoint.csv | where-object{$_.'Server Name' -eq 'ABCARCTPACS01'}

    It is good that you used single quotes.  Few new users know how to do that.


    \_(ツ)_/

    • Marked as answer by Winterwolf71 Friday, April 17, 2015 4:31 PM
    Thursday, April 16, 2015 11:05 PM
  • Thank you for your help.
    Friday, April 17, 2015 4:31 PM
  • You are welcome. Easy? Wasn't it?

    \_(ツ)_/

    Friday, April 17, 2015 4:41 PM