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??