导出AD用户信息到 XSL
2011-09-15 11:08
417 查看
$objOU=[ADSI]"LDAP://OU=TEST,OU=XXX
Users,DC=XXX,DC=intranet,DC=asia"
$searcher=new-object directoryservices.directorysearcher($objOU)
$searcher.Filter="(&(objectclass=user))"
$users=$searcher.findall()
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $True
$workbook = $excel.Workbooks.add()
$workbook.workSheets.item(2).delete()
$workbook.workSheets.item(2).delete()
$workbook.WorkSheets.item(1).Name = "UsersInfo"
$sheet = $workbook.WorkSheets.Item("UsersInfo")
$sheet.cells.item(1,1) = "Name"
$sheet.cells.item(1,2) = "Description"
$sheet.cells.item(1,3) = "Dep"
$sheet.cells.item(1,4) = "Tel"
$intRow=2
foreach ( $user in $users){
$Path=$user.Path
$account=[ADSI]$Path
$sheet.cells.item($intRow,1) = $account.Name.Value
$sheet.cells.item($intRow,2) = $account.description.Value
$sheet.cells.item($intRow,3) = $account.physicaldeliveryofficename.Value
$sheet.cells.item($intRow,4) = $account.telephonenumber.Value
$intRow++
}
$strPath = "D:\Test.xls"
IF(Test-Path $strPath)
{
Remove-Item $strPath
$Excel.ActiveWorkbook.SaveAs($strPath)
}
ELSE
{
$Excel.ActiveWorkbook.SaveAs($strPath)
}
$Excel.Quit()
Users,DC=XXX,DC=intranet,DC=asia"
$searcher=new-object directoryservices.directorysearcher($objOU)
$searcher.Filter="(&(objectclass=user))"
$users=$searcher.findall()
$excel = New-Object -ComObject Excel.Application
$excel.Visible = $True
$workbook = $excel.Workbooks.add()
$workbook.workSheets.item(2).delete()
$workbook.workSheets.item(2).delete()
$workbook.WorkSheets.item(1).Name = "UsersInfo"
$sheet = $workbook.WorkSheets.Item("UsersInfo")
$sheet.cells.item(1,1) = "Name"
$sheet.cells.item(1,2) = "Description"
$sheet.cells.item(1,3) = "Dep"
$sheet.cells.item(1,4) = "Tel"
$intRow=2
foreach ( $user in $users){
$Path=$user.Path
$account=[ADSI]$Path
$sheet.cells.item($intRow,1) = $account.Name.Value
$sheet.cells.item($intRow,2) = $account.description.Value
$sheet.cells.item($intRow,3) = $account.physicaldeliveryofficename.Value
$sheet.cells.item($intRow,4) = $account.telephonenumber.Value
$intRow++
}
$strPath = "D:\Test.xls"
IF(Test-Path $strPath)
{
Remove-Item $strPath
$Excel.ActiveWorkbook.SaveAs($strPath)
}
ELSE
{
$Excel.ActiveWorkbook.SaveAs($strPath)
}
$Excel.Quit()
相关文章推荐
- vc 导出AD域中用户的用户名 和登录名等信息
- VBScripit 导出AD用户信息
- 批量(导入导出)迁移AD中的用户信息和密码到新环境中,同时保持用户在MOSS中的权限【addusers,ldifde,copypwd,UserInfo,tp_SystemID】
- 批量(导入导出)迁移AD中的用户信息和密码到新环境中,同时保持用户在MOSS中的权限【addusers,ldifde,copypwd,UserInfo,tp_SystemID】
- 如何用powershell导出AD用户信息到CSV中并发送到本地邮箱中
- Oracle数据库exp与expdp方式导入导出时改变数据库表空间及用户信息
- C#通过Excel导出用户信息
- 无责任Windows Azure SDK .NET开发入门篇三[使用Azure AD 管理用户信息--3.2 Create创建用户]
- 数据导入:从文本文件导入用户信息。数据导出:将用户信息导出到文本文件。 带参数的写法 适合登陆使用
- Dsquery工具导出AD信息
- C# 获取AD用户信息
- Powershell-AD:查询并导出OU信息
- csvde导出计算机/用户信息
- 获取Ad用户信息
- 怎么导出SQL所有用户表的字段信息
- SharePoint自动化部署,利用PowerShell 导出/导入AD中的用户
- LDAP方式连接AD获取用户信息
- SharePoint站点中用户信息与AD用户信息的“不一致”问题