Useful commands for Windows

How many users are logged on/connected to a server

 NET SESSION | FIND /C "\"

Who is logged on to a computer

NBTSTAT -a remotecomputer | FIND "<03>" | FIND /I /V "remotecomputer"

What is the full name for this login name

NET USER loginname /DOMAIN | FIND /I " name "
or
DSQUERY USER -samid *loginname* | DSGET USER -samid -display

When did someone last change his password

NET USER loginname /DOMAIN | FIND /I "Password last set"

How to reset someone’s password

NET USER loginname newpassword /DOMAIN

Is someone’s account locked

NET USER loginname /DOMAIN | FIND /I "Account active"

How to unlock a locked account

NET USER loginname /DOMAIN /ACTIVE:YES

or, if the password needs to be reset as well:

NET USER loginname newpassword /DOMAIN /ACTIVE:YES

List all domains and workgroups in the network

NET VIEW /DOMAIN

List all computers in the network

NET VIEW

List all domain controllers

2000 Server:
NETDOM QUERY /D:MyDomain DC
2003 Server:
DSQUERY Server

List all drivers on any PC

DRIVERQUERY /V /FO CSV > %ComputerName%.csv

List all printers on any PC

WMIC /Node:remote_PC Path Win32_Printer Get DeviceID

Disable Windows Firewall for domain only

NETSH Firewall Set OpMode Mode = DISABLE Profile = DOMAIN

Completely disable Windows Firewall

SC [ \Remote_computer ] Stop SharedAccess
SC [ \Remote_computer ] Config SharedAccess start= disabled

List all local administrators

 

NET LOCALGROUP Administrators

Delete a computer account

NETDOM /DOMAIN:MyDomain MEMBER \computer2Bdeleted /DELETE