Adding Addtional output on export csv

Welcome Forums General PowerShell Q&A Adding Addtional output on export csv

Viewing 4 reply threads
  • Author
    Posts
    • #202535
      Participant
      Topics: 9
      Replies: 10
      Points: 80
      Rank: Member

      $DN=’OU=ZY,DC=XXX,DC=net’
      $Members=Get-ADObject -LDAPFilter ‘(name=*)’ -SearchBase $DN -server <Servername> | where {$_.Objectclass -notlike “*organizational*”} | select-object -Property name, distinguishedname, Objectclass

      $membersDN | export-csv c:\temp\oumembers.csv -NoTypeInformation

      The export-csv gives me the options as required, but also need the additional column for DN. Once I get the details, I will loop this out. For now I am checking how to add this additional column which will be same across.

    • #202544
      Participant
      Topics: 4
      Replies: 1908
      Points: 4,259
      Helping Hand
      Rank: Community Hero

      The export-csv gives me the options as required, …

      Really? That’s nearly impossible. 😉 You save the query output in a variable $Members but you export a variable $membersDN. That shouldn’t work at all.

    • #202550
      Participant
      Topics: 9
      Replies: 10
      Points: 80
      Rank: Member

      The export-csv gives me the options as required, …

      Really? That’s nearly impossible. 😉 You save the query output in a variable $Members but you export a variable $membersDN. That shouldn’t work at all.

      My bad it’s $members only. I was doing some R&D and paste the wrong one. The output gives the desired result, but need the additional column of DN

    • #202553
      Participant
      Topics: 4
      Replies: 1908
      Points: 4,259
      Helping Hand
      Rank: Community Hero

      The output gives the desired result, but need the additional column of DN

      Hmmm … I’m pretty unsure if it’s just an inaccuracy in your wording. DN is short for Distinguished Name. And if your code works as you state it you already have a cloumn with the DN – it’s called “distinguishedname“.

    • #202556
      OK
      Participant
      Topics: 6
      Replies: 17
      Points: 80
      Rank: Member

      You are operating on objects, use add-member to add

      Example

      $a=get-process |select name,id,cpu
      $b=(get-process).Parent
      $i=0
      $b|%{$a[$i]|add-member line $_;$i++}
      $a
      0..($b.length)|%{$a[$_]|add-member custom $_}
      $a
Viewing 4 reply threads
  • You must be logged in to reply to this topic.