Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Scott Lowe http://blog.scottlowe.org

« Newer Snippets
Older Snippets »
Showing 1-9 of 9 total  RSS 

Reset WINS Configuration to DHCP

Resets the WINS configuration on the specified remote PC (per the /node:PCname parameter) to obtain WINS addresses from DHCP

   1  
   2  wmic /node:PCname process call create 'cmd.exe /c “netsh interface ip set wins name=”Local Area Connection“ source=dhcp”'

Reset DNS Configuration to DHCP

Resets the DNS configuration on the specified remote PC (per the /node:PCname parameter) to obtain DNS addresses from DHCP

   1  
   2  wmic /node:PCname process call create 'cmd.exe /c “netsh interface ip set dns name=”Local Area Connection“ source=dhcp”'

Listing Services Running As a User Account

Lists all services that are running as a user account (not running as LocalSystem, LocalService, or NetworkService)

   1  
   2  wmic service where (StartName!=LocalSystemand StartName!=NT AUTHORITY\\LocalServiceand StartName!=NT AUTHORITY\\NetworkService”) get Caption,StartName
   3  

Find Users With a Blank UPN

Locates users with a blank user principal name, sometimes caused by migration utilities

   1  
   2  adfind -b dc=domain,dc=com -f "(&(objectCategory=Person)(objectClass=User)(!userPrincipalName=*))" sAMAccountName -csv > blank-upn-list.csv

Set DNS Suffix Search Order Remotely

Uses WMIC to connect to a list of computers in an input file (one computer name per line) and sets the DNS suffix search order

   1  
   2  wmic /node:@input.txt /failfast:on nicconfig call SetDNSSuffixSearchOrder (child.domain.com,domain.com,otherdomain.com)

Find Accounts With No Home Directory

Finds all accounts that do not have a home directory set

   1  
   2  dsquery * "dc=domain,dc=com" -scope subtree -filter "(&(objectClass=user)(!homeDirectory=*))" -limit 0

Find Accounts Created After a Specific Date

Query to find all accounts created after a specific date; this example finds accounts created after 10/5/06

   1  
   2  adfind -b dc=domain,dc=com -f "(&(objectCategory=Person)(objectClass=User)(whenCreated>=20061005000000.0Z))" name displayName -csv

Find Disabled Accounts

Query to find disabled accounts in Active Directory, uses a bitwise comparison for accuracy

   1  
   2  dsquery * dc=domain,dc=com -filter "(&(objectCategory=Person)(objectClass=User)(!userAccountControl:1.2.840.113556.1.4.803:=2))" -limit 0

E-Mail and UPN Mismatch

Log Parser command line to check for user accounts
where the UPN does not match the e-mail address

   1  
   2  logparser -i:ads -o:csv -stats:off "SELECT cn, 
   3  TO_LOWERCASE(SUBSTR(mail,0,LAST_INDEX_OF(mail,'@'))) as mailPrefix, TO_LOWERCASE(SUBSTR(userPrincipalName,0,LAST_INDEX_OF
   4  (userPrincipalName,'@'))) as uPNPrefix 
   5  FROM 'ldap://dc.domain.com/cn=Users,dc=domain,dc=com' 
   6  WHERE NOT (mailPrefix = uPNPrefix)" -objClass:user >> output.csv
« Newer Snippets
Older Snippets »
Showing 1-9 of 9 total  RSS