Thursday, December 4, 2008

enumerate service accounts

Clean Up After Terminated Windows Administrators


Enumerate Service Accounts from jeff hick's scripts

Change passwords on service accounts. 


Listing 15.21 Changing a Service Account Password









Script to Audit Service Accounts




If you keep getting request to create multiple (service) accounts in AD , you got to think what PowerShell can do for this task. 
================================= scripts ================
 Go to a command line and type:
dsquery user -desc *service account* > serviceaccounts.txt

or

dsquery user -desc *service account* | dsget user -samid -desc
(Where | is shift-\)

*************************








Open Active Directory Users and Computers
Right-click Saved Queries
Select New, Query
Give it a name like "service accounts"
Click Define Query
Select Users, Contacts and Groups in Find box
Click Advanced tab
Click Field button
Select User, Description
Type *service account* in the value field
Click Add
Click OK
Now that you have a list, you can drag and drop these accounts into a new OU.

*********************************

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
 
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
 
Set objRootDSE = GetObject("LDAP://RootDSE")
 
objCommand.CommandText = _
 " & objRootDSE.Get("defaultNamingContext") & ">;" & _
 "(&(objectCategory=person)(objectClass=user)(description=*service account*));" & _
 "displayName,distinguishedName;subtree"
 
Set objRecordSet = objCommand.Execute
 
strResults = """Display Name"",""Distinguished Name"""
If objRecordset.EOF Then
        Wscript.Echo "No user accounts found."
Else
        While Not objRecordset.EOF
                strResults = strResults & VbCrLf & """" & objRecordset.Fields("displayName") & """,""" & objRecordset.Fields("distinguishedName") & """"
                objRecordset.MoveNext
        Wend
End If
 
objConnection.Close
 
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("Results.csv", True)
objFile.Write strResults
objFile.Close
Set objFile = Nothing
 
MsgBox "Done. Please see Results.csv"



No comments: