0

I'm trying to create a report which will get two sets of information, Group name and domain. The problem is that the information will be output into one column instead of two for example:

Group Member                   Domain
thisIsGroupMember,Domain

but I want it to be like this:

Group Member                   Domain
thisIsGroupMember,             Domain

I also try export-csv but the created csv file only show

Length
32

Here's my code:

 $appName = $findone.properties.name
 $domain = (($findone.properties.adspath -split ',')[3].substring(3)
 $inputstring = "$appName,$domain"
 out-file -FilePath "C:\Test\Result.csv" -append -inputObject $inputstring

1 Answer 1

1

If your code iterates through a list of objects pulled from AD you can use something like this:

# your foreach code
{
   ...
   $appName = $findone.properties.name
   $domain = (($findone.properties.adspath -split ',')[3].substring(3)
   $output += ,(New-Object -TypeName psobject -Property @{"Group Member"=$appName;"Domain"=$domain})
}
$output | Export-Csv "C:\Test\Result.csv" 

$output is an array of objects being created on the fly with $appName and $domain values. It will then nicely export to a csv after all AD objects are processed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.