Title: Automating System Administration
1Automating System Administration
Yaniv Weinberg Windows 2003 User Group Leader
2What we will cover
- Remote Helpdesk Information Gathering
- Remote Helpdesk Administration
- Active Directory Administration
- Printer Management
- WMIC Administration
3Agenda
- Remote Helpdesk Information
- Remote Helpdesk Administration
- Active Directory Administration
- Printer Management
- WMIC Administration
4Remote Helpdesk InformationRetrieve General
System Information
- Systeminfo.exe
- Retrieves basic system information
- OS version and role, hardware properties, etc.
- Example systeminfo /S \\wkstn1 "c\sysinfo.txt
- Queries wkstn1 and outputs to c\sysinfo.txt
- SC
- Communicates with Service Control Manager
- Retrieves services running on a system
- Example sc \\server2 query
- Queries services running on Server2
- Article ID 252340 How to Create and Start a
Service on a Remote Computer By Using the
Command-Line or a Script
5Remote Helpdesk Information Viewing System
Information
6Remote Helpdesk InformationRetrieve Information
from Logs
- DriverQuery
- Displays list of installed device drivers
- Retrieves status of device drivers
- Example driverquery /s server2
- Displays list of drivers on server2
- EventQuery
- Lists event properties from Event Logs
- Can be output to a file
- Example eventquery /L application
- Lists events from the Application Event log
7Remote Helpdesk Information Retrieve Information
about Hardware
- Getmac
- Displays the MAC address for a system
- Example getmac /s server2
- Gets the MAC address for Server2
- Freedisk
- Displays amount of free disk space on a hard
drive - Can be used to determine if the required amount
of space is available - Example freedisk 4GB
- Will display a success if there is 4 GB free
8Remote Helpdesk Information Group Policy
Information
- GPResult
- Displays Resultant Set of Policy (RSoP) for user
and computer - Can display simple or verbose information
- Can be used to determine if the correct set of
Group Policies have been applied - Example gpresult /user KimA
- Displays the Group Policies for User KimA
9Remote Helpdesk Information Usage Scenarios
- Systeminfo
- Helpdesk can gather system information
- Verify versions etc.
- Driverquery
- Helpdesk can capture driver information to make
sure the correct drivers are installed - Freedisk
- Can be used prior to deploying software to
confirm enough hard drive space is available
10Demonstration 1Remote Helpdesk Information
Gathering Gather Information from a Remote
System
11Agenda
- Remote Helpdesk Information
- Remote Helpdesk Administration
- Active Directory Administration
- Printer Management
- WMIC Administration
12Remote Helpdesk AdministrationRetrieve
Information About Open Files
- Openfiles
- Displays list of files open on a system
- Can be used to see if a file is in use
- Example openfiles /query s server2
- Displays list of open files on Server2
- Scenarios
- Determine what files are open
- Determine files that are locked
- Backup Senarios
- Can use to disconnect open files
13Remote Helpdesk AdministrationRetrieve
Information About Processes
- Tasklist
- Displays a list of currently running processes on
a local or remote system - Replaces Windows 2000 Resource Kit Utility
Tlist.exe - Can be run against a local or remote system
- Example tasklist /s server2
- Displays the processes running on server2
- Example tasklist /FI "MEMUSAGE GE 10000
- Display all the processes that use more then 10
MB Memory - Scenarios
- Determine what processes are running
- Determine process IDs
14Remote Helpdesk AdministrationStop the Process
From Running
- Taskkill
- Used when you need to terminate an errant process
- Terminate process based on PID or Image Name
- Replaces Windows 2000 Resource Kit utility
kill.exe - Run against local or remote system
- Example taskkill /IM notepad.exe
- Terminates Notepad.exe running on the local
system - Scenarios
- Kill a process thats consuming server resources
- Kill a process that has data files locked
15Remote Helpdesk AdministrationUsing Tasklist and
Taskkill
Process1 Process2 Process3
TaskList
Taskkill PID3
File Server
Helpdesk
16Demonstration 2Remote Helpdesk
AdministrationUsing Tasklist and Taskkill to
Terminate a Process
17Agenda
- Remote Helpdesk Information
- Remote Helpdesk Administration
- Active Directory Administration
- Printer Management
- WMIC Administration
18Active Directory AdministrationActive Directory
Path Names
- Components of Active Directory Path
- dc Domain Component
- ou Organization Unit
- cn Common Name used for users or containers
- Example
- cnkima,cnusers,dcworldwideimporters,dccom
- User account is kima, in the Users container, in
the WorldWideImporters.com domain - Example
- cnaaronc,ousales,dcworldwideimporters, dccom
- User account is aaronc, in the Sales OU, in the
WorldWideImIporters.com domain
19Active Directory AdministrationAdding Objects to
Active Directory
- DSAdd
- Adds users, groups, computers, OUs, etc.
- Can be used to automate bulk changes to the
directory - Example
- dsadd user "CNKimA,OUSales,DCworldwideimporters
,DCcom - Adds a user KimA to the Sales OU in the
WorldWideImporters.com domain
20Active Directory AdministrationRemoving Objects
from Active Directory
- DSRM
- Removes objects from the directory
- Can automate repetitive tasks such as stale
account deletion - Example
- dsrm -noprompt -c "cnNeilC,OUSales,DCworldwidei
mporters,DCcom - Removes NeilC from the Sales OU in the
WorldWideImporters.com domain
21Active Directory AdministrationRetrieving Data
from Active Directory
- DSGet
- Retrieves information about a single object in
the directory - User properties such as group memberships etc.
- DSQuery
- Retrieves information about multiple objects in a
specified path (container or OU) - Usage scenarios
- Generate information and statistics about Active
Directory Objects - Group memberships, phone numbers, etc.
22Active Directory AdministrationRetrieving Data
from Active Directory
- DSGet example
- dsget user "CNKimA,OUSales,DCworldwideimporters
, DCCom" -memberof expand - Retrieves information about User KimA including
what groups and OUs she belongs to - DSQuery example
- dsquery user "OUSales,DCworldwideimporters,DCco
m - Displays the users in the Sales OU
23Active Directory AdministrationMoving Active
Directory Objects
- DSMove
- Moves or renames an object
- Example
- dsmove "CNKimA, OUSales, DCworldwideimporters,
DCcom" -newparent "OUMarketing and Finance,
DCworldwideimporters, DCcom" - Moves user KimA to the Sales OU from the
Marketing and Finance OU - Usage scenarios
- Relocate user accounts after a reorganization
24Active Directory AdministrationModifying Active
Directory objects
- DSMod
- Modifies an existing object in Active Directory
- Can be used to modify name or group membership
- Example
- dsmod user "CNSeanA, OUSales,
DCworldwideimporters, DCcom -pwd Abcd123
-mustchpwd yes - This will change the users password, and require
them to change it next time they logon. - Usage scenarios
- Change passwords in bulk
- Update group memberships in bulk
25Active Directory AdministrationUsing Scripts for
Repetitive Tasks
26Demonstration 3Active Directory
AdministrationAutomating Active Directory Tasks
27Agenda
- Remote Helpdesk Information
- Remote Helpdesk Administration
- Active Directory Administration
- Printer Management
- WMIC Administration
28Printer ManagementPrinter Configuration
- Prncnfg
- Displays printer configuration on a local or
remote system - Sets printer properties (name, priority, port
etc.) - Example
- prncnfg g s Server1 p HPLaser
- Displays the configuration of HPLaser on Server1
- Usage scenarios
- Set and verify printer configuration properties.
29Printer ManagementAdding Printers and Ports
- Prnport
- Used to create a TCP/IP Printer port
- Example prnport a s Server1 r 10.0.1.24
- Creates a new TCP/IP port with the address
10.0.1.24 on Server1 - Prnmngr
- Manages local and remote printers
- Delete a printer, get driver information, etc.
- Example prnmngr d HPLaser s Server1
- Deletes HPLaser from Server1
30Printer ManagementPrinter Driver Management
- Prndrvr
- Used to manage printer drivers
- Add/verify/delete installed printer drivers
- Examples
- prndrvr l s Server1
- Lists the printer drivers installed on Server1
- Prndrvr a m PrinterDriver v X e Windows NT
X86 s Server1 - Adds a PrinterDriver (version X) to Server1 and
specifies that it is a Windows NT driver
31Printer ManagementPrint Job Management
- Prnjobs
- Manage print jobs
- Pause, resume, cancel, list etc.
- Example prnjobs l s Server1
- Displays list of Print jobs on Server1
- Prnqctl
- This command manages print queues
- Example prnqctl m HPLaser s Server1
- Resumes the HPLaser printer on Server1
32Printer ManagementPRNQCTL Used to Resume a
Printer
PrintJob1 PrintJob2
prnqctl m printer
Paused
Ready
Helpdesk
33Demonstration 4Printer ManagementControlling
and Managing Remote Printers
34Agenda
- Remote Helpdesk Information
- Remote Helpdesk Administration
- Active Directory Administration
- Printer Management
- WMIC Administration
35WMIC AdministrationWindows Management
Instrumentation
- Simple Command-line interface to Windows
Management Instrumentation - Provides a simple command-line interface
- Supports an interactive mode
- Interoperates with existing shells and utilities
- Can be extended by scripts
36WMIC AdministrationView Process Identifiers
- View process identifiers for running processes
- Can be used to help identify processes to be
terminated - Example WMIC PROCESS WHERE Namesvchost.exe
GET name, processid - Obtains PIDs for all processes name svchost.exe
37WMIC AdministrationStarting an Application
- Can be used to start and stop processes
- The Helpdesk staff could use this to remotely
- Start an application such a backup task
- Example WMIC PROCESS CALL Create calc.exe
- This will start the Windows Calculator applet
- This are just a few things you can do with WMIC
38WMIC AdministrationUsage Scenarios
- Easily script administrative tasks
- Configure computer settings
- Launch, terminate, and control system processes
- Query local and remote machines
- View operating system and hard drive information
- Query events and output results into formatted
HTML tables
39Demonstration 5WMIC AdministrationCommon uses
for WMIC
40Session Summary
- 60 New command line tools
- Manage and retrieve system configuration
- Tools are remoteable
- Work on local and remote systems
- Provide credentials at run-time
- Automate common or complex tasks
- Call tools from scripts
- Reduce scripting time
- Use these tools to do complex tasks
41For More Information
- Main TechNet Web site at www.microsoft.com/technet
- This sessions resource page
- www.microsoft.com/technet/tnt1-83
42For More Information
- Windows Server 2003
- www.microsoft.com/WindowsServer2003
- Windows Server 2003 Technology Centers
- http//www.microsoft.com/windowsserver2003/technol
ogies/default.mspx