-
-
Save irwins/41d5eaf3465b2987c138179a0262cd24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$dsADUsers = New-Object System.Data.DataSet | |
$dtADUsers = New-Object System.Data.Datatable 'ADUsers' | |
$columnsADUsers = Get-ADUser -Identity guest -Properties * | | |
Get-Member -MemberType Property | | |
Select-Object -ExpandProperty Name | |
$columnsADUsers | | |
Foreach-Object{ | |
[void]$dtADUsers.Columns.Add("$($_)") | |
} | |
Get-ADUser -Filter * -Properties * | | |
Foreach-Object{ | |
$Row = $dtADUsers.NewRow() | |
foreach ($column in $columnsADUsers){ | |
$Row["$($column)"] = if($_.$column -ne $null){($_ | Select-Object -ExpandProperty $column) -join "`n"}else{$null} | |
} | |
$dtADUsers.Rows.Add($Row) | |
} | |
$dsADUsers.Tables.Add($dtADUsers) | |
$dtADUsers.WriteXml('c:\scripts\export\dsa\dtADUsers.xml') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment