Import-Module ActiveDirectory
$userList = Get-Aduser -Filter *
foreach($user in $userlist)
{
[array]$userGroups = Add-ADPrincipalGroupMembership -Identity $user.samaccountname
$result = $user.samaccountname + "`t" + $user.displayName + "`t" + ($userGroups.name -join "; ")
Out-file -InputObject $result -FilePath "C:\result.csv" -Append # Если в файл вывод не нужен, то "Write-Host $result"
}
[System.Data.datatable]$test = Get-ADOrganizationalUnit -filter * -SearchBase "dc=DOMAIN,dc=local" | Out-DataTable
UserParameter=users.list, "chcp 65001 & whoami"
system.run["chcp 65001 & whoami"]