xbast1x
Goto Top

AD User exportieren mit name, surname, username, date of creation, date of password expiration, state of the user (enabled disabled), date of disabling

Hallo zusammen,

ist es möglich einen Export der User im AD anzustoßen (in eine csv oder txt etc.) in welcher die Daten neben Accountname, name, surname, username, date of creation, date of password expiration, state of the user (enabled/disabled), date of disabling enthalten sind?


Grüße

Content-Key: 253301

Url: https://administrator.de/contentid/253301

Printed on: April 24, 2024 at 22:04 o'clock

Member: Pjordorf
Pjordorf Oct 29, 2014 at 12:46:25 (UTC)
Goto Top
Hallo,

Zitat von @xbast1x:
ist es möglich einen Export der User im AD anzustoßen
Ja.

disabling enthalten sind?
Welche Attribute musst du schauen.

Vielleicht so etwa mit dem CSVDE teil deines OSes?
http://www.computerperformance.co.uk/Logon/Logon_CSVDE_Export.htm
http://technet.microsoft.com/en-us/library/cc732101.aspx
http://ss64.com/nt/csvde.html
http://www.petri.com/using-csvde-ldifde-export-active-directory-snapsho ...

Oder solle es Powershell sein?
http://www.computerperformance.co.uk/powershell/powershell_qad_export_c ...

Gruß,
Peter
Member: colinardo
colinardo Oct 29, 2014 updated at 13:16:06 (UTC)
Goto Top
Member: xbast1x
xbast1x Oct 29, 2014 at 14:03:56 (UTC)
Goto Top
Uwe,

woher bekomme ich die Feldbezeichnung wenn ich das ganze per Powershell machen möchte für name, surname, username, date of creation, date of password expiration, state of the user (enabled disabled), date of disabling ?

Danke vorab.
Member: colinardo
colinardo Oct 29, 2014 updated at 14:46:56 (UTC)
Goto Top
get-aduser -Filter * -properties * -ResultSetSize $null | select DisplayName,SamAccountName,PasswordLastSet,Created,Enabled,@{name='Passwort läuft ab am';e={if($_."msDS-UserPasswordExpiryTimeComputed"){([datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")).DateTime}}} | export-csv "C:\userexport.csv" -delimiter ";" -NoType -Encoding UTF8
Member: xbast1x
xbast1x Oct 30, 2014 at 06:52:55 (UTC)
Goto Top
Folgende Meldung in der PS bekomme ich:

The term 'get-aduser' is not recognized as a cmdlet, function, operable program, or script file. Verify the term and tr
y again.
At line:1 char:11

back-to-topget-aduser <<<< -Filter * -properties * -ResultSetSize $null | select DisplayName,SamAccountName,PasswordLastSet,Cre

ated,Enabled,@{name='Passwort läuft ab am';e={if($_."msDS-UserPasswordExpiryTimeComputed"){([datetime]::FromFileTime($_
."msDS-UserPasswordExpiryTimeComputed")).DateTime}}} | export-csv "C:\userexport.csv" -delimiter ";" -NoType -Encoding
UTF8
Member: mylurid
mylurid Oct 30, 2014 updated at 06:59:55 (UTC)
Goto Top
The term 'get-aduser' is not recognized as a cmdlet, function, operable program, or script file.

Sagt doch eigentlich schon alles aus, oder? face-wink

Welche PS Version nutzt du?
Auf welchem OS hast du die Abfrage losgetreten?
Setz den Befehl mal auf einem Domain Controller ab oder installier dir die RSAT Tools auf dem Rechner..
Member: xbast1x
xbast1x Oct 30, 2014 at 07:01:12 (UTC)
Goto Top
Ich benutze PS 1.0
OS: Win Server 2003
Ich habe den Befehl von einem DC gestartet, daraufhin erschien die Meldung.
Member: colinardo
colinardo Oct 30, 2014 updated at 07:56:06 (UTC)
Goto Top
Zitat von @xbast1x:

Ich benutze PS 1.0
OS: Win Server 2003
Ich habe den Befehl von einem DC gestartet, daraufhin erschien die Meldung.
oh je ... dann brauchst du aber noch ein Import-Module ActiveDirectory vor dem Code. Ob das aber auf Server 2003 damit läuft, kann ich gerade nicht vollkommen sicher sagen, der 2K3 Server ist bei mir nämlich schon längst in der Versenkung verschwunden ....
Member: xbast1x
xbast1x Oct 30, 2014 at 08:46:00 (UTC)
Goto Top
Ich muss mich leider noch damit bis Frühjahr 2015 rumschlagen ;) Ich werde der Sache mit dem Import Module nachgehen.

Danke
Member: xbast1x
xbast1x Oct 30, 2014 at 09:49:17 (UTC)
Goto Top
Bei der Install stellt er sich quer und weigert sich (Nicht kompatibel).

Gibt es noch eine Möglichkeit die Benutzer bei einem 2003'er mit den o.g. Informationen auszulesen..?

Grüße Sebastian.
Member: colinardo
colinardo Oct 30, 2014 at 10:29:08 (UTC)
Goto Top
Zitat von @xbast1x:
Gibt es noch eine Möglichkeit die Benutzer bei einem 2003'er mit den o.g. Informationen auszulesen..?
hatte ich oben bereits verlinkt:
Einfaches Tool um AD Felder zu exportieren
Das sollte auch von einem Client aus mit einem User der genügend Leserechte im AD hat, laufen ...
Member: xbast1x
xbast1x Oct 30, 2014 updated at 12:27:36 (UTC)
Goto Top
Ich habe jetzt das Script in dem Link ausprobiert (DC etc. auf meine Firma geändert) , folgende FM bekomme ich.

PS H:\> powershell.exe -ExecutionPolicy RemoteSigned -File "C:\aduser.ps1"  
2
3
4
5
6
7
8
9
10
11
12
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

33
13
14
32
ConvertFrom-StringData : Datenzeile "15." weist nicht das "Name=Wert"-Format auf.  
Bei C:\aduser.ps1:125 Zeichen:66
+     $all += new-Object PSObject -Property (ConvertFrom-StringData <<<<  -StringData $propertyHT)
    + CategoryInfo          : InvalidOperation: (:) [ConvertFrom-StringData], PSInvalidOperationException
    + FullyQualifiedErrorId : InvalidOperation,Microsoft.PowerShell.Commands.ConvertFromStringDataCommand

usw..
Member: colinardo
colinardo Oct 30, 2014 updated at 12:28:30 (UTC)
Goto Top
Eine Referenzauswertung wurde vom Server zurückgesendet
Das kann viele Ursachen haben:
  • der User hat nicht genügend Rechte
  • Zertifikate sind abgelaufen
  • UAC
  • du nutzt einen PC der nicht in der Domain ist
  • ...
Member: xbast1x
xbast1x Oct 30, 2014 at 12:29:20 (UTC)
Goto Top
also ich hab es mit einem domainadmin ausgeführt, Zertifkat ist valid, UAC ist aus.

Mhm oder gibt es ein externes Tool welches ich auf dem DC installieren kann welcher mir die Infos ausliest?
Member: colinardo
Solution colinardo Oct 30, 2014 updated at 13:36:06 (UTC)
Goto Top
Member: colinardo
Solution colinardo Oct 30, 2014 updated at 13:36:03 (UTC)
Goto Top
Zitat von @xbast1x:
Mhm oder gibt es ein externes Tool welches ich auf dem DC installieren kann welcher mir die Infos ausliest?
Das kann alles mögliche eines AD exportieren (auch in der Demo-Version) ....http://www.systemtools.com/hyena/report.htm
Member: xbast1x
xbast1x Oct 30, 2014 at 13:19:17 (UTC)
Goto Top
Danke für den Link,

habe ein Script gefunden welches funktioniert, dieses liefert einige Infos, jedoch nicht alle die ich benötige.

Ich habe gedacht, wenn ich folgende Zeile um die Werte "Creation,Passwordlastset,enabled" ergänze sollte das ganze funktionieren. Das Script läuft dann auf Fehler

"
' Comma delimited list of attribute values to retrieve.
varAttributes = "name,samaccountname,distinguishedname,mail""

' ExportADUsers.vbs  
' Sample VBScript to Find and Export AD users into CSV file .  
' Author: http://www.morgantechspace.com/  
' ------------------------------------------------------'  
 
Option Explicit
 
' Initialize required variables.  
Dim adoCommand, adoConnection
Dim varBaseDN, varFilter, varAttributes
Dim objRootDSE, varDNSDomain, strQuery, adoRecordset
Dim objFSO, objCSVFile
 
' Setup ADO objects.  
Set adoCommand = CreateObject("ADODB.Command")  
Set adoConnection = CreateObject("ADODB.Connection")  
adoConnection.Provider = "ADsDSOObject"  
adoConnection.Open "Active Directory Provider"  
Set adoCommand.ActiveConnection = adoConnection
 
' Search entire Active Directory domain.  
Set objRootDSE = GetObject("LDAP://RootDSE")  
 
varDNSDomain = objRootDSE.Get("defaultNamingContext")  
varBaseDN = "<LDAP://" & varDNSDomain & ">"  
 
' varBaseDN is Domain DN, you can give your own OU DN instead of  
' getting from "defaultNamingContext"  
' like varBaseDN = "<LDAP://OU=ALT,DC=alt.asclepion.com,DC=com>"  
 
' Filter for user objects.  
varFilter = "(&(objectCategory=person)(objectClass=user))"  
 
' Comma delimited list of attribute values to retrieve.  
varAttributes = "name,samaccountname,distinguishedname,mail"  
 
' Construct the LDAP syntax query.  
strQuery = varBaseDN & ";" & varFilter & ";" & varAttributes & ";subtree"  
adoCommand.CommandText = strQuery
adoCommand.Properties("Page Size") = 1000  
adoCommand.Properties("Timeout") = 20  
adoCommand.Properties("Cache Results") = False  
 
' Run the query.  
Set adoRecordset = adoCommand.Execute
 
' Create CSV file  
Const ForWriting = 2
 
Set objFSO = CreateObject("Scripting.FileSystemObject")  
 
' Here, I have given CSV file path as "ADUsers.csv", this will create ADUsers.csv file  
' where you placed and execute this VB Script file. You can give your own file path  
' like "C:\Users\Administrator\Desktop\ADUsers.csv"  
 
Set objCSVFile = objFSO.CreateTextFile("ADUsers.csv", _  
    ForWriting, True)
 
' Write selected AD Attributes as CSV columns(first line)  
 objCSVFile.Write varAttributes
 
 objCSVFile.Writeline ' New Line  
 
' Enumerate the resulting recordset.  
Do Until adoRecordset.EOF
 
   ' Retrieve values and write into CSV file.  
 
     objCSVFile.Write adoRecordset.Fields("name").Value & ","  
     objCSVFile.Write adoRecordset.Fields("samaccountname").Value & ","  
     objCSVFile.Write adoRecordset.Fields("distinguishedname").Value & ","  
     objCSVFile.Write adoRecordset.Fields("mail").Value & ""  
     objCSVFile.Writeline  ' New Line  
 
    ' Move to the next record in the recordset.  
    adoRecordset.MoveNext
Loop
 
 objCSVFile.Close
 
' close ado connections.  
adoRecordset.Close
adoConnection.Close
 
' Active Directory User properites are exported Successfully as CSV File  
Member: colinardo
colinardo Oct 30, 2014 at 13:35:27 (UTC)
Goto Top
Zitat von @xbast1x:
habe ein Script gefunden welches funktioniert, dieses liefert einige Infos, jedoch nicht alle die ich benötige.
naja meins läuft auch wenn man es richtig macht face-wink
Ich habe gedacht, wenn ich folgende Zeile um die Werte "Creation,Passwordlastset,enabled" ergänze sollte das ganze
funktionieren. Das Script läuft dann auf Fehler
nope das tut es nicht, das das nicht die LDAP Namen sind, die gehen so nur in der Powershell-Variante. Die LDAP-Namen erhältst du z.B. in der ADUC auf einem UserAccount > Kontextmenü > Eigenschaften > TAB: Attribut-Editor
(Zur info das sind erweiterte Features die du erst in der ADUC MMC unter Ansicht > Erweiterte Features aktivieren musst)

Die entsprechenden Werte lauten: whenCreated, pwdLastSet ("enabled" musst du aus userAccountControl auslesen das ist Zahlenkodiert)

zusätzlich müssen die gewünschten Werte natürlich in Zeilen 69-72 hinzugefügt werden...
Member: xbast1x
xbast1x Oct 30, 2014 at 13:35:56 (UTC)
Goto Top
Alles gut unsere Antworten haben sich ein bissl überschnitten,

das Tool macht das was ich möchte.

Vielen Vielen Dank Uwe!!