Formatting data from multiple jobs

Welcome Forums General PowerShell Q&A Formatting data from multiple jobs

This topic contains 1 reply, has 2 voices, and was last updated by

 
Member
3 years, 11 months ago.

  • Author
    Posts
  • #20826

    Participant
    Points: 0
    Rank: Member

    Hi guys,

    Quick question.

    If I'm running jobs that return an array of MAC addresses, how would I add a column of hostnames from a text file that it's getting content from to match the MACs?

    Can't seem to figure this one out. If you need a sample of my script I'll add it soon, going to lunch right now.

    Thanks for your help.

  • #20828

    Member
    Points: 0
    Rank: Member

    What's in your text file now, hostnames or MAC addresses? If you're reading one and looking up the other, then you just need to build an object that has both properties. Something along these lines (assuming a fake function called Get-MacAddress is doing the work of turning a hostname into a MAC):

    Get-Content hostnames.txt |
    ForEach-Object {
        New-Object psobject -Property @{
            ComputerName = $_
            MacAddress = Get-MacAddress -ComputerName $_
        }
    }
    

The topic ‘Formatting data from multiple jobs’ is closed to new replies.