$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()