Introduction to PowerShell
For years, Unix and Linux administrators have
experienced the flexibility of very powerful command shells for
administrators. Complex administrative tasks that might have required
hours of work using GUI tools could easily be accomplished within
minutes, using the powerful command line shell technologies in these
OSs.
Over the past few years, Microsoft has
been developing and evolving PowerShell to bring the same command line
administrative power found in Unix and Linux to the Windows platform.
PowerShell is quickly becoming the administrative tool of choice for
many administrators. Exchange Server 2007 was the first major product
shipped by Microsoft that used PowerShell as the foundation for all
administrative functions. The Exchange 2007 GUI tools actually call
underlying PowerShell commands and scripts in the background. This
concept was such a success with Exchange administrators that it is
quickly becoming the standard administrative framework for most
Microsoft products, including Windows Server. Windows Server 2008 R2
comes packed with PowerShell cmdlets for administrating everything from
Windows services to Active Directory. If you have not taken the time to
learn the PowerShell basics, now is the time to do so.
Windows Server 2008 R2 administration tools
You will be
introduced to various Windows Server 2008 R2 administrative tools.
However, there are some key tools you should familiarize yourself with
up front. These tools provide administration of some of the most basic,
yet most critical aspects of the Windows OS.
Event Viewer
The event
viewer provides very detailed logs about errors, warnings, and general
information regarding events that occur in the OS or applications
hosted on the system. The event viewer is crucial not only for
understanding problems when they occur, but also for monitoring changes
and security of healthy systems.
Services
The Services console provides you with
information regarding all Windows Services and their state. The
Services console allows you to start, stop, and restart services
installed on the server. Familiarize yourself with the services
console. You will use it often.
Local Users and Groups
The Local Users and Groups console allows you
to manage users and groups local to the server. Local Users and Groups
are used to control who has what level of access to the local computer
for which they reside. Local Users and Groups do not extend beyond the local computer in which
they are created. If you plan on deploying an Active Directory domain,
you may not spend a lot of time administering local users and groups;
nevertheless, it is important that you understand how they can be used
to provide or restrict access to a given server.
Storage
The Storage console is the main administrative
tool for managing Windows disk drives. You
learned how to use the Storage console to create new volumes to be used
by the server. The storage console can also be used to extend and
shrink volumes as well as assign or change drive letters assigned to
volumes and partitions. The Storage console is also used to initialize
and configure newly added disk drives.
Task Scheduler
Windows Server 2008 R2 comes with a built-in
task scheduler allowing administrators to create automated jobs or
tasks. These jobs can be set up to run based on various criteria, such
as scheduled times or when a specific event occurs. These jobs run
without requiring administrative input. Jobs can be set up to perform
serveral actions including running scripts, displaying message dialogs,
or sending email messages. An example of a scheduled task would be a
weekly disk defragmentation job that needs to run off hours when an
administrator is not available to manually start the job. Scheduled
tasks can also be used to perform tasks, such as backups or running
command line utilities.
The Task Scheduler management console is located in Server Manager under the Configuration node as seen in Figure 6. You will notice that there will already be a list of predefined tasks configured.
To create a new scheduled task, perform the following:
-
Open Server Manager.
-
Expand the Configuration node and right click on Task Scheduler. Then choose the option Create Task.
-
The main task window will be displayed as seen in Figure 7.
Enter a descriptive name for the task and configure security options
for the task. Security options define how the task runs and how it can
run when no user is logged on. If the task will need access to
resources on other systems, you may need to run it under the context of
another user account. If this is required, you can enter the account
information by clicking on the Change User or Group button. After
configuring information on the General tab, select the Triggers tab.
-
The Triggers section is used to define what
events, including scheduled times, trigger the scheduled task to run.
As you can see in Figure 8,
several different triggers can be used to start a scheduled task. You
can also select multiple triggers that can be used to kick off a
scheduled task. After you define the triggers used to start the task,
select the Actions tab.
-
You can now use the Actions tab to define
what actions are to be performed in the event that the scheduled task
is triggered to run. Like triggers, you can define multiple actions to
occur. For example, you could have the task run a batch file to copy
files from one server to another and also send an email notifying an
administrator that the task ran. After selecting the actions to
perform, select the Conditions tab.
-
Scheduled tasks can use conditions to ensure
that tasks run only under certain circumstances. For example, you may
only want a task that makes use of lot of processing power to only
start if the computer is idle for 30 minutes. After defining any
optional conditions, you may want to tie to the scheduled task, select
the Settings tab.
-
Using the settings section, you can define
additional settings that should be applied to the scheduled task. For
example, you may want the task to stop if it has been running for more
than 6 h or you may want the task to rerun if it fails the first time.
As you can see from Figure 9,
there are various additional settings you can tie to a scheduled task.
After you have configured any additional settings for the scheduled
task, click on OK to create the new task.
After the task is completed, it will be
displayed in the Task Scheduler console in Server Manager. If you want
to test the task, you can simply right click on the task and choose the
Run option.
|