?
Solved

display two arrays elements use table

Posted on 2011-05-11
2
Medium Priority
?
582 Views
Last Modified: 2012-05-11
Hi

I created two simple arrays of string
for example:
$users = {"James","Michelle","George","Louis", ...etc}
$manager = {"Sarah","Jessica","Bill","William", ...etc}

for objects in powershell
is possible to use table like
$a = @{Expression={$_.Name};Label="Name";width=50}, `
@{Expression={$_.protocol};Label="Protocol";width=15}}

get-process | Format-able $a

i tried use this with normal array but i can't  figure out how i can do this
i would like to display array elements like this
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
                      Users                                                   Managers
                   ++++++++                                              +++++++++
                      James                                                   Sarah
                     Michelle                                                 Jessica
                     George                                                   Bill
                       Louis                                                    William


thanks
0
Comment
Question by:ang3lus
2 Comments
 
LVL 13

Accepted Solution

by:
soostibi earned 2000 total points
ID: 35744086
Here you are:

$users = @("James","Michelle","George","Louis")
$manager = @("Sarah","Jessica","Bill","William")

$a = @{Expression={$_.Users};Label="Users";width=50}, @{Expression={$_.Managers};Label="Managers";width=15}

$users | ForEach-Object {$i=0} {
    New-Object -TypeName PSObject -Property @{
        Users = $_
        Managers = $manager[$i]
    }
    $i++
} | Format-Table $a

Open in new window

0
 

Author Closing Comment

by:ang3lus
ID: 35744145
thanks very much
 A++++++++++++++++
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question