Populate a Data-Table from Get-ADUser command

Welcome Forums General PowerShell Q&A Populate a Data-Table from Get-ADUser command

Viewing 3 reply threads
  • Author
    Posts
    • #188215
      Participant
      Topics: 1
      Replies: 1
      Points: 13
      Rank: Member

      I want to store the output from the Get-ADUser command into a Data-Table but, as far as I can tell, this command returns a System.Array. I know I can step through the array to populate a Data-Table but this is very slow.

      Is there a way to store the output from the Get-ADUser command straight into a Data-Table?

      Thanks.

    • #188239
      Participant
      Topics: 1
      Replies: 1639
      Points: 3,104
      Helping Hand
      Rank: Community Hero

      What do you mean with

      ... straight into a Data-Table

      You could use Format-Table or Export-CSV.

      • #188290
        Participant
        Topics: 1
        Replies: 1
        Points: 13
        Rank: Member

        I have data from a SQL SELECT statement which is stored in a DataTable object. I want to join this with the output from the Get-ADUser command for some later processing. Unfortunately this requires both sides to be DataTable objects.

        Running the "$x = Get-ADUser | Format-Table" still results in $x.Get-Type() being System.Array so that doesn't solve my problem.

    • #188389
      Participant
      Topics: 1
      Replies: 1639
      Points: 3,104
      Helping Hand
      Rank: Community Hero

      You could use a PSCustomObject or calculated properties to combine properties of different objects. I could imagine that it would be helpful to see more of the code you're using. 😉

    • #188398
      Participant
      Topics: 10
      Replies: 1284
      Points: 1,084
      Helping Hand
      Rank: Community Hero

      I've used this function (Out-DataTable) for Bulk Insert operations into SQL:

      https://gallery.technet.microsoft.com/scriptcenter/4208a159-a52e-4b99-83d4-8048468d29dd

Viewing 3 reply threads
  • You must be logged in to reply to this topic.