settingsLogin | Registersettings
Es tu primera visita? Te invitamos a visitar nuestra sección de preguntas frecuentes FAQ!
x
Show Menu

Exportar Atributos (Por Defecto y Nuevos) de Usuarios del Active Directory en Windows Server 2008 R2?

0 votos

Estimados, tengo sistema operativo Windows Server 2008 R2 y Controladores de dominio Adicionales, se creo nuevos atributos en el AD

Se usa un PowerShell para exportar los atributos del ad entre ellos los nuevos atributos , pero cuando termina el proceso a pesar que tiene información estos atributos , en el excel generado no muestra nada (muestra  información únicamente  de los atributos que vienen de por si con el windows server ), gracias por su apoyo .

Envió el archivo ExportAD.ps1

Este PowerShel lo ejecuto desde Quest.ActiveRoles.ADManagement instalado previamente .de
http://www.quest.com/powershell/activeroles-server.aspx

-------------------------------------------------------------------------------------------------------------------------------
Start-Transcript
# call excel for writing the results
$objExcel = new-object -comobject excel.application
$workbook = $objExcel.Workbooks.Add()
$worksheet=$workbook.ActiveSheet
$objExcel.Visible = $False
$cells=$worksheet.Cells
# define top level cell
$cells.item(1,1)="Name"
$cells.item(1,2)="sAMAccountName"
$cells.item(1,3)="userPrincipalName"
$cells.item(1,4)="givenName"
$cells.item(1,5)="initials"
$cells.item(1,6)="sn"
$cells.item(1,7)="extensionattribute1"
$cells.item(1,8)="PrimarySMTPAddress"
$cells.item(1,9)="Office"
$cells.item(1,10)="Department"
$cells.item(1,11)="Company"
$cells.item(1,12)="st"
$cells.item(1,13)="displayName"
$cells.item(1,14)="physicalDeliveryOfficeName"
$cells.item(1,15)="telephoneNumber"
$cells.item(1,16)="mail"
$cells.item(1,17)="wWWHomePage"
$cells.item(1,18)="profilePath"
$cells.item(1,19)="scriptPath"
$cells.item(1,20)="homeDirectory"
$cells.item(1,21)="homeDrive"
$cells.item(1,22)="title"
$cells.item(1,23)="manager"
$cells.item(1,24)="homePhone"
$cells.item(1,25)="pager"
$cells.item(1,26)="mobile"
$cells.item(1,27)="facsimileTelephoneNumber"
$cells.item(1,28)="ipphone"
$cells.item(1,29)="info"
$cells.item(1,30)="co"
$cells.item(1,31)="departmentNumber"
$cells.item(1,32)="fSAUbicacion"   --> (este por ejemplo es un atributo nuevo que tiene contenido)
$cells.item(1,33)="fSAestablecimiento" --> (Atributo Nuevo)
$cells.item(1,34)="division"
$cells.item(1,35)="fSAdivision"  --> (Atributo Nuevo)
$cells.item(1,36)="streetAddress"
$cells.item(1,37)="postOfficeBox"
$cells.item(1,38)="l"
$cells.item(1,39)="postalCode"
$cells.item(1,40)="c"
#intitialize row out of the loop
$row = 2
#import quest management Shell
if ( (Get-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue) -eq $null )
{
    Add-PsSnapin Quest.ActiveRoles.ADManagement
}
$data = get-qaduser -IncludedProperties "CO", "extensionattribute1"
-sizelimit 0
#loop thru users
foreach ($i in $data)
{
#initialize column within the loop so that it always loop back to column 1
$col = 1
$userid=$i.Name
$samaccountnamed=$i.sAMAccountName
$userprincipalnamed=$i.userPrincipalName
$FisrtName=$i.givenName
$initialsd=$i.initials
$LastName=$i.sn
$Employeeid=$i.extensionattribute1
$email=$i.PrimarySMTPAddress
$office=$i.Office
$Department=$i.Department
$Company=$i.Company
$state=$i.st
$displaynamed=$i.displayName
$physicalDeliveryOfficeNamed=$i.physicalDeliveryOfficeName
$telephoneNumberd=$i.telephoneNumber
$maild=$i.mail
$wWWHomePaged=$i.wWWHomePage
$profilePathd=$i.profilePath
$scriptPathd=$i.scriptPath
$homeDirectoryd=$i.homeDirectory
$homeDrived=$i.homeDrive
$titled=$i.title
$managerd=$i.manager
$homePhoned=$i.homePhone
$pagerd=$i.pager
$mobiled=$i.mobile
$facsimileTelephoneNumberd=$i.facsimileTelephoneNumber
$ipphoned=$i.ipphone
$infod=$i.info
$cod=$i.co
$departmentNumberd=$i.departmentNumber
$fSAUbicaciond=$i.fSAUbicacion
$fSAestablecimientod=$i.fSAestablecimiento
$divisiond=$i.division
$fSAdivisiond=$i.fSAdivision
$streetAddressd=$i.streetAddress
$postOfficeBoxd=$i.postOfficeBox
$ld=$i.l
$postalCoded=$i.postalCode
$cd=$i.c
Write-host "Processing.................................$userid"
$cells.item($row,$col) = $userid
$col++
$cells.item($row,$col) = $samaccountnamed
$col++
$cells.item($row,$col) = $userprincipalnamed
$col++
$cells.item($row,$col) = $FisrtName
$col++
$cells.item($row,$col) = $initialsd
$col++
$cells.item($row,$col) = $LastName
$col++
$cells.item($row,$col) = $Employeeid
$col++
$cells.item($row,$col) = $email
$col++
$cells.item($row,$col) = $office
$col++
$cells.item($row,$col) = $Department
$col++
$cells.item($row,$col) = $Company
$col++
$cells.item($row,$col) = $state
$col++
$cells.item($row,$col) = $displaynamed
$col++
$cells.item($row,$col) = $physicalDeliveryOfficeNamed
$col++
$cells.item($row,$col) = $telephoneNumberd
$col++
$cells.item($row,$col) = $maild
$col++
$cells.item($row,$col) = $wWWHomePaged
$col++
$cells.item($row,$col) = $profilePathd
$col++
$cells.item($row,$col) = $scriptPathd
$col++
$cells.item($row,$col) = $homeDirectoryd
$col++
$cells.item($row,$col) = $homeDrived
$col++
$cells.item($row,$col) = $titled
$col++
$cells.item($row,$col) = $managerd
$col++
$cells.item($row,$col) = $homePhoned
$col++
$cells.item($row,$col) = $pagerd
$col++
$cells.item($row,$col) = $mobiled
$col++
$cells.item($row,$col) = $facsimileTelephoneNumberd
$col++
$cells.item($row,$col) = $ipphoned
$col++
$cells.item($row,$col) = $infod
$col++
$cells.item($row,$col) = $cod
$col++
$cells.item($row,$col) = $departmentNumberd
$col++
$cells.item($row,$col) = $fSAUbicaciond
$col++
$cells.item($row,$col) = $fSAestablecimientod
$col++
$cells.item($row,$col) = $divisiond
$col++
$cells.item($row,$col) = $fSAdivisiond
$col++
$cells.item($row,$col) = $streetAddressd
$col++
$cells.item($row,$col) = $postOfficeBoxd
$col++
$cells.item($row,$col) = $ld
$col++
$cells.item($row,$col) = $postalCoded
$col++
$cells.item($row,$col) = $cd
$col++
$row++
}
#formatting excel
$range = $objExcel.Range("A2").CurrentRegion
$range.ColumnWidth = 50
$range.Borders.Color = 0
$range.Borders.Weight = 2
$range.Interior.ColorIndex = 37
$range.Font.Bold = $false
$range.HorizontalAlignment = 3
# Headings in Bold
$cells.item(1,1).font.bold=$True
$cells.item(1,2).font.bold=$True
$cells.item(1,3).font.bold=$True
$cells.item(1,4).font.bold=$True
$cells.item(1,5).font.bold=$True
$cells.item(1,6).font.bold=$True
$cells.item(1,7).font.bold=$True
$cells.item(1,8).font.bold=$True
$cells.item(1,9).font.bold=$True
$cells.item(1,10).font.bold=$True
$cells.item(1,11).font.bold=$True
$cells.item(1,12).font.bold=$True
$cells.item(1,13).font.bold=$True
$cells.item(1,14).font.bold=$True
$cells.item(1,15).font.bold=$True
$cells.item(1,16).font.bold=$True
$cells.item(1,17).font.bold=$True
$cells.item(1,18).font.bold=$True
$cells.item(1,19).font.bold=$True
$cells.item(1,20).font.bold=$True
$cells.item(1,21).font.bold=$True
$cells.item(1,22).font.bold=$True
$cells.item(1,23).font.bold=$True
$cells.item(1,24).font.bold=$True
$cells.item(1,25).font.bold=$True
$cells.item(1,26).font.bold=$True
$cells.item(1,27).font.bold=$True
$cells.item(1,28).font.bold=$True
$cells.item(1,29).font.bold=$True
$cells.item(1,30).font.bold=$True
$cells.item(1,31).font.bold=$True
$cells.item(1,32).font.bold=$True
$cells.item(1,33).font.bold=$True
$cells.item(1,34).font.bold=$True
$cells.item(1,35).font.bold=$True
$cells.item(1,36).font.bold=$True
$cells.item(1,37).font.bold=$True
$cells.item(1,38).font.bold=$True
$cells.item(1,39).font.bold=$True
$cells.item(1,40).font.bold=$True
#save the excel file
$filepath = "c:\scripts\exportAD13032013.xlsx"
$workbook.saveas($filepath)
$workbook.close()
$objExcel.Quit()
Stop-Transcript
##############################################################################################

Si alguno de ustedes le paso algo parecido , favor de comentar como lo solucionaron , gracias

por  
editado por

1 Respuesta

0 votos
Hola anonimo,

desconozco los motivos por los cuales no te funciona la generacion, el script parece estar bien, pero te dejo alternativas.

1) http://www.joeware.net/freetools/tools/adfind/index.htm

2) http://www.dovestones.com/active-directory-export/

3) http://www.computerperformance.co.uk/Logon/Logon_CSVDE_Export.htm

Exitos !
por (4.6k puntos)  
...