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

Kannel parameters (escape codes)

%k the keyword in the SMS request (i.e., the first word in the SMS message)

%s next word from the SMS message, starting with the second one (i.e., the first word, the keyword, is not included); problematic characters for URLs are encoded (e.g., ’+’ becomes ’%2B’)

%S same as %s, but ’*’ is converted to ’~’ (useful when user enters a URL) and URL encoding isn’t done (all others do URL encode)

%r words not yet used by %s; e.g., if the message is «FOO BAR FOOBAR BAZ», and the has been one %s, %r will mean «FOOBAR BAZ»
%a all words of the SMS message, including the first
one, with spaces squeezed to one
%b the original SMS message, in a binary form
%t the time the message was sent, formatted as
«YYYY-MM-DD HH:MM», e.g., «1999-09-21
14:18»