Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
3Activity
0 of .
Results for:
No results containing your search query
P. 1
Useful Commands for Windows Administrators

Useful Commands for Windows Administrators

Ratings: (0)|Views: 267 |Likes:
Published by CPUManager

More info:

Published by: CPUManager on Nov 24, 2010
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

12/09/2010

pdf

text

original

 
Useful commands for Windows administratorshttp://www.robvanderwoude.com/ntadmincommands.php[21/Nov/2010 13:41:59]
Useful commandsfor Windows administrators
Managing a Windows 2000 Active Directory with about 100 servers, over 1500 computersand 35 sites, the following commands often helped me answer questions or solveproblems.Most commands are "one-liners", but for some I had to make an exception and go to theright directory first.These commands could all be used in batch files, though some may need some "parsing"with
to retrieve only the required substrings from the displayed information. 
Notes:(1)
Commands that use external, or third party, or non-native utilitiescontain hyperlinks to these utilities' download sites. 
(2)
Replace command arguments displayed in
italics
with your ownvalues. 
(3)
Commands or utilities that require Windows Server 2003 are markedbright blue.
Warning:
 Most commands on this page are very powerful tools.Like most powerful tools they could cause a lot of damage in the handsof insufficiently skilled users.Treat these commands like you would (or should) treat a chainsaw: withutmost care.
Do not use them if you do not fully understand what theydo or how they do it.
 
Useful commands for Windows administratorshttp://www.robvanderwoude.com/ntadmincommands.php[21/Nov/2010 13:41:59]
How many users are logged on/connected to aserver?
Sometimes we may need to know how many users are logged on to a (file) server, likemaybe when there is a performance degradation.At the server's console itself, with native commands only:
 NETSESSION | FIND /C "\\"
Remotely, with the help of SysInternals' PSTools:
 PSEXEC\\
servername
NET SESSION | FIND /C "\\"
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. Back to the index 
Who is logged on to a computer?
We often need to know who is currently logged on to a remote computer.With native Windows (up to and including XP) commands only:
NBTSTAT -a
remotecomputer 
| FIND "<03>" | FIND /I /V "
remotecomputer 
"
The first name in the list usually is the logged on user (try playing with the
NETNAME
command to learn more about the names displayed by
NBTSTAT
).This is the
fastest
way to find the logged on user name, and the results that you
do
get
are
correct, but
NBTSTAT
won't always return a user name, even when a user
is
logged on.
Note:
Unfortunately, NBTSTAT is no longer available in Windows 7 (not sure aboutVista)Using
(Windows XP Professional and later):
 WMIC/Node:
remotecomputer 
ComputerSystem Get UserName
 
Useful commands for Windows administratorshttp://www.robvanderwoude.com/ntadmincommands.php[21/Nov/2010 13:41:59]
This is arguably the most reliable (native) command to find out who is logged on.With the help of SysInternals'PSTools:
 PSLOGGEDON-L \\
remotecomputer 
or:
 PSEXEC\\
remotecomputer 
NET CONFIG WORKSTATION | FIND /I " name "
or:
 PSEXEC\\
remotecomputer 
NET NAME
or for Windows XP only:
 PSEXEC\\
remotecomputer 
 NETSHDIAG SHOW COMPUTER /V | FIND /i "username"
Using
(Windows 2000 and later):
 FOR /F%%A IN ('REG Query\\
remotecomputer 
\HKU ˆ|FINDSTR/R /B/C:"HKEY_USERS\\S-1-5-[0-9][0-9]-[0-9-]*$"') DO (FOR /F "tokens=3 delims=\" %%B IN ('REG Query"\\
remotecomputer 
\%%A\Volatile Environment"') DO (SET LoggedinUser=%%B))
or for Windows 7:
 FOR /F%%A IN ('REG Query\\
remotecomputer 
\HKU /K /F "S-1-5-21-" ˆ|FINDSTR/R /B /C:"HKEY_USERS\\S-1-5-[0-9][0-9]-[0-9-]*$"') DO (') DO (FOR /F "tokens=2*" %%B IN ('REG Query "\\
remotecomputer 
\%%~A\VolatileEnvironment" /V "UserName" ˆ| FIND /V ":"') DO (SET LoggedinUser=%%C))NETSH
and
WMIC
are for XP or later, and are the most reliable of all commands shownhere.
WMIC
requires WMI enabled remote computers and Windows XP on the administrator'scomputer;
NETSH
requires Windows XP on the local
and
remote computers.
PSLOGGEDON
is a more accurate solution than
NBTSTAT
, but it will return the last logged onuser 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 versionused.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
page.For Windows NT 4 and 2000: use
NBTSTAT
(fast, but it won't always return the username!), and only switch to
REG
if 
NBTSTAT
doesn't return a user name (modify the REGcommand for Windows NT 4).For Windows XP: if you want to search lots of computers for logged on users, Irecommend you try
NBTSTAT
first (fast, but it won't always return the user name!), andonly 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: Jirí Janyška (WMIC command) and Matthew W. Helton (NETSH command). Back to the index 
What is this collegue's login name?

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->