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

How to configure TCP/IP settings from the Command Prompt in Windows

In order to configure TCP/IP settings such as the IP address, Subnet Mask, Default Gateway, DNS and WINS addresses and many other options you can use Netsh.exe.

With Netsh.exe you can easily view your TCP/IP settings. Type the following command in a Command Prompt window (CMD.EXE):

netsh interface ip show config

With Netsh.exe, you can easily configure your computer’s IP address and other TCP/IP related settings. For example:

The following command configures the interface named Local Area Connection with the static IP address 10.0.0.100, the subnet mask of 255.255.255.0, and a default gateway of 10.0.0.1:

netsh interface ip set address name=»Local Area Connection» static 10.0.0.100 255.255.255.0 10.0.0.1 1 (The above is one long line)

If you want to export your current ip settings:

netsh -c interface dump > c:mySettings.txt 

If you want to import your ip settings:

netsh -f c:mySettings.txt

or instead of -f

netsh exec c:mySettings.txt

To automatically obatin an IP address using DHCP:

netsh interface ip set address «Local Area Connection» dhcp

DNS settings:

netsh interface ip set dns «Local Area Connection» static 10.0.0.254

WINS settings:

netsh interface ip set wins «Local Area Connection» static 10.0.0.254

Auto DNS settings:

netsh interface ip set dns «Local Area Connection» dhcp

Usefull links:

Link one and Link two