Running a command shell under a privileged account.
Many of these commands will require more than domain user privileges to yield meaningful results. To run the command window with alternate credentials (e.g. an ADS-based Acsup-Computer Support !account), go to Start-Run... and type on one line:
runas.exe /user:ads\!username %comspec%
(substitute your !account username for !username)
Querying Active Directory users, groups and computers remotely
1. To find out detailed information about a user account: net user username /domainC:\>net user etbain /domain
The request will be processed at a domain controller for domain ads.uwaterloo.ca.
User name etbain
Full Name Bain, E. Trevor
Comment
User's comment
Country code 000 (System Default)
Account active Yes
Account expires Never
Password last set 8/8/2003 9:30 AM
Password expires Never
Password changeable 8/8/2003 9:30 AM
Password required Yes
User may change password Yes
Workstations allowed All
Logon script
User profile \\uwfile\profiles$\etbain
Home directory \\jam\istus$\etbain
Last logon 1/23/2004 8:58 AM
Logon hours allowed All
Local Group Memberships *IST-FolderRedirection
Global Group memberships *IST-RdiskWR *IST-TSPC
*IST-HSG *IST-AlertCentreAdmins
*IST-NTtools *OR-WebLogs
*IST-W2KTools *SYCAMORE_Win_Web_auth
*IST *Domain Users
*Depot-Administrators
The command completed successfully.
The above listing is 'scrunched', check here for what the listing will actually look like (in a new window).
2. To find out what groups a user is in: showgrps ads\username
net user username /domain
C:\>showgrps ads\etbain
User: [ads\etbain], is a member of:
ADS\Depot-Administrators
ADS\Domain Users
\Everyone
ADS\IST
ADS\IST-AlertCentreAdmins
ADS\IST-FolderRedirection
ADS\IST-HSG
ADS\IST-NTtools
ADS\IST-RdiskWR
ADS\IST-TSPC
ADS\IST-W2KTools
ADS\OR-WebLogs
ADS\SYCAMORE_Win_Web_auth
ISTPC76\Users
Shwgrps only displays group membership for the user whereas the Net command dumps a lot of information about the account (see above).
3. To find out who is a member of a particular group:
• showmbrs ads\groupname
• global groupame ads
• net group groupname /domain
C:\>showmbrs ads\IST-HSG
Members of global group [ADS\IST-HSG]:
manfred
tim
henders
kassa
crutter
gleiher
schepers
srbreen
lycke
ryawney
etbain
C:\>global ist-hsg ads
manfred
tim
henders
kassa
crutter
gleiher
schepers
srbreen
lycke
ryawney
etbain
C:\>net group ist-hsg /domain
The request will be processed at a domain controller for domain ads.uwaterloo.ca.
Group name IST-HSG
Comment istrd$ Hsgstuff folder
Members
------------------------------
crutter etbain gleiher
henders kassa lycke
manfred ryawney schepers
srbreen tim
The command completed successfully.
The net group command is formatted differently than the other two commands (see actual screenshot here in a new window). It also shows the description or comment associated with the group. This information is often useful for determining what resource the group is related to (see dsquery in 4 below also).
4. To find out the ADS description for a given group:
dsquery group -name groupname | dsget group -desc
C:\>dsquery group -name IST-HSG | dsget group -desc
desc
istrd$ Hsgstuff folder
dsget succeeded
Because we assign descriptions to most of our groups, running this command will provide you with some idea as to why this group exists and for what resources (if any) this group controls access.
5. To find out where (which OU) a user account resides in ADS:
dsquery user -samid username
C:\>dsquery user -samid etbain
"CN=E. Trevor Bain (etbain), OU=Users, OU=Info Systems & Technology, OU=Academic Support, DC=ads, DC=uwaterloo, DC=ca"
The result is in distinguished name format. CN is common name and the first OU is where the account resides (usually in a "Users" OU in our ADS). Normally, the next OU is department/faculty.
6. To find out where a computer is in ADS:
dsquery computer -name computername
C:\>dsquery computer -name istpc76
"CN=istpc76, OU=Computers, OU=Info Systems & Technology, OU=Academic Support, DC=ads, DC=uwaterloo, DC=ca"
Again, the result is in distinguished name format. CN is common name and the first OU is where the computer account resides (usually in a "Computers" OU in our ADS). Normally, the next OU is department/faculty.
7. To find out what groups an ADS computer is a member of:
dsquery computer -name computername | dsget computer -memberof
C:\>dsquery computer -name istpc76 | dsget computer -memberof
"CN=Software Upgrade June 2003, OU=Security Groups, OU=Academic Support, DC=ads, DC=uwaterloo, DC=ca"
"CN=OffXP_SP2,OU=Security Groups, OU=Academic Support, DC=ads, DC=uwaterloo, DC=ca"
"CN=Standard Applications, OU=Security Groups, OU=Academic Support, DC=ads, DC=uwaterloo, DC=ca"
"CN=Domain Computers, CN=Users, DC=ads, DC=uwaterloo, DC=ca"
Again, the result is in distinguished name format. CN is common name of the group and the first OU is where the security group resides (usually in a "Security Groups" OU in our ADS). Normally, the next OU is department/faculty.
8. To find out detailed information about an ADS-based computer:
The srvinfo command will display a lot of information about a client computer (too much?) including: the machine name, OS version (5.0 is Windows 2000, 5.1 is XP), the Service Pack level and installed patches, disk size and services running.
srvinfo \\computername
C:\>srvinfo \\istpc76
Server Name: istpc76
Security: Users
NT Type: NT Advanced Server -
Version: 5.1
Build: 2600, Service Pack 1
Current Type: Uniprocessor Free
Product Name: Microsoft Windows XP
Registered Owner: IST Academic Support
Registered Organization: University of Waterloo
ProductID: 55555-000-1111111-11111
Original Install Date: Mon Mar 10 14:24:02 2003
Domain: ADS
PDC: \\DOUGLASFIR
IP Address: 129.97.109.28
CPU[0]: x86 Family 6 Model 8 Stepping 3: 866 MHz
Hotfixes:
[Q828026]:
[Q817606]:
[Q817287]:
:
:
[Q329390]:
[Q329170]:
[KB821557]:
Drive: [FileSys] [ Size ] [ Free ] [ Used ]
C$ NTFS 14002 6694 7308
E$ FAT32
Services:
[Stopped] Alerter
[Stopped] Application Layer Gateway Service
[Stopped] Application Management
[Running] Windows Audio
[Running] Background Intelligent Transfer Service
[Stopped] Computer Browser
:
:
[Stopped] WMI Performance Adapter
[Running] Automatic Updates
[Running] Wireless Zero Configuration
Network Card [0]:
System Up Time: 0 Days, 23 Hr, 31 Min, 29 Sec
Short Cuts to GUI tools
Okay, so the GUI tools are good for some tasks but getting to them can be torturous. Start-Run and then type can be much faster:
• Command Window - cmd
• Local Security Policy - secpol.msc
• Services - services.msc
• Event Log Viewer - eventvwr
• Server Manager - srvmgr
• System Information - winmsd
• Active Directory Users & Computers - dsa.msc
• Internet Services Manager - iis.msc
• Computer Management - compmgmt.msc (admittedly, right clicking on My Computer and selecting Manage is quicker!)
Scheduled Tasks
At
Used to query or scheduled tasks on or from WindowsNT and Windows 2000 machines (see at /?) for details.
Soon
Can be used to schedule a task in the very near future. It is the same as running the at command to schedule a task in the next minute without watching the clock. (see soon /?) for details.
SchTasks (XP/2003)
SchTasks is the command line interface to the Scheduled Task control panel applet. Any job listed in the Scheduled Tasks dialogue can be manipulated via schtasks. For example, to query jobs on a remote server:
schtasks /query /s servername
If you add a /v option to this, you get a very detailed listing of the tasks.
Group Policy
gpresult (Win2K/XP/2003)
secedit /refreshpolicy machine_policy (Win2K)
secedit /refreshpolicy user_policy (Win2K)
gpupdate (XP/2003)