Useful Commands
Useful Commands
These commands could all be used in batch files, though some may need some "parsing"
with FOR /F to retrieve only the required substrings from the displayed information.
Notes: (1) Commands that use external, or third party, or non-native utilities contain
hyperlinks to these utilities' download sites.
(2) Replace command arguments displayed in italics with your own values.
(3) Commands or utilities that require Windows Server 2003 are marked bright
blue.
Warning: Most commands on this page are very powerful tools.
Like most powerful tools they could cause a lot of damage in the hands of
insufficiently skilled users.
Treat these commands like you would (or should) treat a chainsaw: with
utmost care. Do not use them if you do not fully understand what
they do or how they do it.
Any damage caused using these commands is completely your own
responsibility.
How many users are logged on/connected to a server (and who are they)?
Who is logged on to a computer?
What is this collegue's login name?
What is the full name for this login name?
What groups is this user a member of?
What permissions does a user have on this directory?
When did someone last change his password?
How do I reset someone's password?
Is someone's account locked?
How to unlock a locked account
Make sure a local user's password never expires
Make sure a local user's password will expire
List all domains and workgroups in the network
List all computers in the network
List all domain controllers
Find the primary domain controller
List all member servers
List all workstations
Delete a computer account
"I need an up-to-date list of disk space usage for all servers, on my desk in 5
minutes"
List all drivers on any PC
List all printers on any PC
List all local administrators
Locate rogue DHCP servers
Disable Windows Firewall for domain only
Completely disable Windows Firewall (not recommended)
Is IP v4 supported on this computer?
Is IP v6 supported on this computer?
Related links
By replacing FIND /C "\\" by FIND "\\" (removing the /C switch) you'll get a list of
logged on users instead of just the number of users.
Note: Unfortunately, NBTSTAT is no longer available in Windows 7 (not sure about Vista)
This is arguably the most reliable (native) command to find out who is logged on.
PSLOGGEDON -L \\remotecomputer
or:
or:
or for Windows 7:
PSLOGGEDON is a more accurate solution than NBTSTAT, but it will return the last logged on
user if no one is currently logged on.
The NET and NBTSTAT commands show more or less identical results, but
the NBTSTAT command is much faster.
The REG command is accurate, but may need to be modified depending on the version used.
As displayed here, the code is written for REG.EXE 2.0 (Windows 2000) and later.
More information on REG versions can be found on my REG Query page.
For Windows NT 4 and 2000: use NBTSTAT (fast, but it won't always return the user name!),
and only switch to REG if NBTSTAT doesn't return a user name (modify the REG command for
Windows NT 4).
For Windows XP: if you want to search lots of computers for logged on users, I recommend
you try NBTSTAT first (fast, but it won't always return the user name!), and only switch
to NETSH, REG or WMIC (accurate) if NBTSTAT doesn't return a user name.
For Windows Vista and later: use REG or WMIC (accurate).
Credits: Jiří Janyška (WMIC command) and Matthew W. Helton (NETSH command).
CD /D d:\directory2check
SHOWACLS /U:domain\userid
Back to the index
NET VIEW
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000
installation CDROM.
DSQUERY Server
or, if you prefer host names only (tip by Jim Christian Flatin):
or, to find the FSMO with (native) Windows Server 2003 commands (Active Directory only):
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000
installation CDROM.
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000
installation CDROM.
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000
installation CDROM.
NETDOM is part of the support tools found in the \SUPPORT directory of the Windows 2000
installation CDROM.
If you have a strict server naming convention, SERVERS.TXT itself can be generated with
the NET command:
or:
or: