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 7955823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:48:27+00:00 2026-06-04T03:48:27+00:00

Im attempting to learn powerscript and was wondering what i’m doing wrong here >

  • 0

Im attempting to learn powerscript and was wondering what i’m doing wrong here >

Foreach($result in $results){
$userEntry = $result.GetDirectoryEntry()

$row = $table.NewRow()
 $row.Name = $userEntry.displayName
 $row.UserID = $userEntry.sAMAccountName
 $row.Department = $userEntry.department

 $table.Rows.Add($row)
}

What i want is for the userdata to output into the proper cells of my table, but what i’m getting is ‘System.DirectoryServices.PropertyValueCollection” repeated in each cell.

when i use the same format but output with

Foreach($result in $results){
$userEntry = $result.GetDirectoryEntry()
Write-Output('' + "Name: " + $userEntry.displayName + "`r`n" + " " +"AccountInfo:"   +$userEntry.sAMAccountName + "`r`n" + " " + "Dept: " + $userEntry.department)

}

It’s correct

what’s the difference with table information?

Thanks everyone, i’m now looking to add this information to a worksheet, have it currently as:

#Excel worksheet
$objExcel = new-object -comobject excel.application 
$objExcel.Visible = $True 
$objWorkbook = $objExcel.Workbooks.Add() 
$objWorksheet = $objWorkbook.Worksheets.Item(1)

but now how would I get my foreach statement values to print onto the excel worksheet, or onto the workbook that is created with the statement??

  • 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-04T03:48:29+00:00Added an answer on June 4, 2026 at 3:48 am

    Try with the value property

    $user.propertyName.value

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Attempting to insert an escape character into a table results in a warning. For
Attempting to learn from doing an implementation of Quicksort, I cannot find out why
I'm attempting to learn a few languages and as such I am doing the
I've been attempting to learn C in my spare time, and other languages (C#,
I am attempting to learn J and the book I am using says this
I'm attempting to learn IronPython, to broaden my .NET horizons. I want to be
I've been attempting to learn programming (in C#) for a few years now. The
I'm attempting to learn Scala so I have decided to implement datastructures with it.
I am new to Ember and attempting to learn parts of it from the
I'm just starting to teach myself objective-c and attempting to learn the cocoa touch

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.