结束语所有ADUsers一个CSV文件 [英] Wrapping all ADUsers in a CSV File

查看:163
本文介绍了结束语所有ADUsers一个CSV文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要检索,在一个CSV文件中,所有的AD用户。但每次我运行我的脚本CSV文件有不同的用户量。

我知道有多达4000个用户......但有时获取500至600的结果。

我发现在我的CSV文件,在最后一排像

 人名, "person.name@email.com","person.name","CN=somewhere,OU=USERS,OU=THERE,OU=HERE,OU=SOMEPLACE,OU=ORG,DC= (这里是部分地方它打破)
 

我注意到,总是在最后一行,结果是休息。是否有限制我的CSV文件?

我想不通,是什么happenning。

  $ PATH =\ Users.csv

$根= [ADSI]''
$搜索=新对象System.DirectoryServices.DirectorySearcher($根)
$ searcher.Filter =(及(对象类=用户))
$ searcher.PageSize = 5000 #iknow最大为1000,但是当我做,我算的结果,它显示了4000+
$ searcher.SizeLimit = 5000


$ COLS =CN,邮件,SAM帐户,的distinguishedName
的foreach($ i的$ COLS){$ searcher.PropertiesToLoad.Add($ I)}

$用户= $ searcher.FindAll()|
  选择-对象@ {E = {$ _ properties.cn}; N =显示名称},
                @ {E = {$ _ properties.mail}; N =电子邮件},
                @ {E = {$ _ properties.samaccountname}; N ='sAMAccountName赋},
                @ {E = {$ _ properties.distinguishedname}; N ='的distinguishedName'}

$用户|出口-CSV $ PATH -Delimiter; -Encoding默认#now使用定界;这样做有问题,我的字符串用逗号
 

解决方案

在我看来,如果你想从一个AD大量的出口数据,可以使用集成的工具,如 LDIFDE.EXE 使用 LDIF 格式,如果你想出口到 CSV 格式,你可以使用 CSVDE.EXE

  CSVDE -f exportfile.csv -dDC = SILOGIX-ESS01,DC =本地-r(&安培;
(对象类=用户))-l显示名称,电子邮件,sAMAccountName赋,distinguishedName来
 

CSVDE.EXE 是土生土长的微软工具。

I want to retrieve, in a CSV file, all AD users. But every time I run my script the CSV file has a different amount of users.

I know there are up to 4000 users... but retrieved sometimes 500 to 600 results.

I noticed in my CSV file, at the last row something like

"Person Name", "person.name@email.com","person.name","CN=somewhere,OU=USERS,OU=THERE,OU=HERE,OU=SOMEPLACE,OU=ORG,DC= (here is the part where it breaks)

I noticed, always in the final row, the result is break. Is there a limit to my CSV file?

I can't figure out, what is happenning.

$path = ".\Users.csv"

$root = [adsi]''
$searcher = New-Object System.DirectoryServices.DirectorySearcher($root)
$searcher.Filter = "(&(objectClass=user))"
$searcher.PageSize = 5000 #iknow the max is 1000, but when i do it, and count my result, its show up 4000+
$searcher.SizeLimit = 5000


$cols = "cn", "mail", "samaccountname", "distinguishedname"
foreach ($i in $cols) {$searcher.PropertiesToLoad.Add($i)}

$users = $searcher.FindAll() |
  Select-Object @{e={$_.properties.cn};n='DisplayName'},
                @{e={$_.properties.mail};n='Email'},
                @{e={$_.properties.samaccountname};n='sAMAccountName'},
                @{e={$_.properties.distinguishedname};n='distinguishedname'}

$users | Export-Csv $path -Delimiter ";" -Encoding Default #now delimiting using ";" to do have problems with my string with commas

解决方案

In my opinion if you want to massively export data from an AD you can use integrated tools like LDIFDE.EXE to use LDIF format, if you want to export to CSV format you can use CSVDE.EXE.

csvde -f exportfile.csv -d "DC=SILOGIX-ESS01,DC=local" -r "(&
(objectClass=user))" -l DisplayName,Email,sAMAccountName,distinguishedname

CSVDE.EXE is a native Microsoft tool.

这篇关于结束语所有ADUsers一个CSV文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆