Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9260359
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:52:18+00:00 2026-06-18T12:52:18+00:00

So I would think that this would be a simple thing to do with

  • 0

So I would think that this would be a simple thing to do with powershell, but I can’t seem to figure out how to make my array output as columns. Below is my script.

$Table = @()

$Employees = Get-ADUser -SearchBase "OU=Emplyoees,DC=mydomain,DC=com" -Filter * -Properties * | ?{$_.telephoneNumber -ne $Null}

ForEach($User in $Employees){$Table += @($User.Name,$user.telephoneNumber)}

($Table)

The output looks similar to:

User1
PhoneNumber1
User2
PhoneNumber2

What I would like it to look like is:

Name        PhoneNumber
User1        PhoneNumber1
User2        PhoneNumber2

Any help would be amazing

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T12:52:19+00:00Added an answer on June 18, 2026 at 12:52 pm

    Try this:

    ForEach($User in $Employees){$Table += ,@($User.Name,$user.telephoneNumber)} #NOTE THE COMMA HERE
    $table | % { $_ -join '`t' } # the `t is a tab, but you can use whatever you want
    

    Edit after comment:

    if is just needed a layout you can try:

     $table | % {  "{0,-20}{1,20}" -f $_[0],$_[1]  } #the 2nd value in {} is the relative cursor position the sign left o right alignment
    

    but why not use just $Employees variable to show the result:

    $Employees = Get-ADUser -SearchBase "OU=Emplyoees,DC=mydomain,DC=com" -Filter * -Properties * | 
    ?{$_.telephoneNumber -ne $Null} | select name, telephonenumber | ft
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple thing that I can't seem to get to work.
Now this might be a very simple thing but I can't think of the
I would have thought that this would be an easy thing to do, but
I would think this would be simple... or that atleast someone else would desire
So I have this idea for a RubyGem that I think would be an
My problem is one that you would think is quite common, but I haven't
I'm trying to do something that i would think to be rather simple. I
This seems like a simple thing to accomplish but I'm not sure if I
I worked all afternoon on a simple thing but cannot seem to get it
I've been trying to do some simple thing in java that in javascript would

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.