SlideShare a Scribd company logo
Professional Sql Server 2008 Administration With
Windows Powershell 1st Edition Ananthakumar
Muthusamy download
https://ebookbell.com/product/professional-sql-
server-2008-administration-with-windows-powershell-1st-edition-
ananthakumar-muthusamy-55089264
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Professional Microsoft Sql Server 2008 Administration Wrox Programmer
To Programmer 1st Edition Brian Knight
https://ebookbell.com/product/professional-microsoft-sql-
server-2008-administration-wrox-programmer-to-programmer-1st-edition-
brian-knight-2195688
Professional Sql Server 2005 Administration Brian Knight Ketan Patel
https://ebookbell.com/product/professional-sql-
server-2005-administration-brian-knight-ketan-patel-978350
Professional Sql Server 2008 Internals And Troubleshooting Christian
Bolton Et Al
https://ebookbell.com/product/professional-sql-server-2008-internals-
and-troubleshooting-christian-bolton-et-al-4106416
Professional Microsoft Sql Server 2008 Reporting Services Wrox
Programmer To Programmer 1st Edition Paul Turley
https://ebookbell.com/product/professional-microsoft-sql-
server-2008-reporting-services-wrox-programmer-to-programmer-1st-
edition-paul-turley-2505620
Professional Microsoft Sql Server 2008 Integration Services Wrox
Programmer To Programmer Brian Knight
https://ebookbell.com/product/professional-microsoft-sql-
server-2008-integration-services-wrox-programmer-to-programmer-brian-
knight-2505622
Professional Microsoft Sql Server 2008 Programming Robert Vieira
https://ebookbell.com/product/professional-microsoft-sql-
server-2008-programming-robert-vieira-5473568
Professional Microsoft Sql Server Analysis Services 2008 With Mdx
Sivakumar Harinath
https://ebookbell.com/product/professional-microsoft-sql-server-
analysis-services-2008-with-mdx-sivakumar-harinath-4106380
Beginning Sql Server 2008 For Developers From Novice To Professional
1st Edition Robin Dewson
https://ebookbell.com/product/beginning-sql-server-2008-for-
developers-from-novice-to-professional-1st-edition-robin-
dewson-1265480
Professional Microsoft Sharepoint 2007 Reporting With Sql Server 2008
Reporting Services 1st Edition Coskun Cavusoglu Jacob J Sanford Reza
Alirezaei
https://ebookbell.com/product/professional-microsoft-
sharepoint-2007-reporting-with-sql-server-2008-reporting-services-1st-
edition-coskun-cavusoglu-jacob-j-sanford-reza-alirezaei-51603320
Professional Sql Server 2008 Administration With Windows Powershell 1st Edition Ananthakumar Muthusamy
Professional
SQL Server®
2008 Administration with
Windows PowerShell™
Muthusamy Anantha Kumar
Yan Pan
Wiley Publishing, Inc.
Professional SQL Server®
2008 Administration with
Windows PowerShell™
Published by
Wiley Publishing, Inc.
10475 Crosspoint Boulevard
Indianapolis, IN 46256
www.wiley.com
Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana
Published by Wiley Publishing, Inc., Indianapolis, Indiana
Published simultaneously in Canada
ISBN: 978-0-470-47728-1
Manufactured in the United States of America
10 9 8 7 6 5 4 3 2 1
Library of Congress Cataloging-in-Publication Data
Kumar, Muthusamy Anantha, 1974-
Microsoft SQL server 2008 administration with Windows Powershell / Muthusamy Anantha Kumar, Yan Pan.
p. cm.
Includes index.
ISBN 978-0-470-47728-1 (paper/website)
1. SQL server. 2. Windows PowerShell (Computer program language) I. Pan, Yan, 1976- II. Title.
QA76.73.W56K96 2009
005.2’82--dc22
2009013304
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any
means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections
107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or
authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood
Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be
addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201)
748-6011, fax (201) 748-6008, or online at www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with
respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including
without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. If professional assistance is required, the services of a competent professional person should be sought.
Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or
Web site is referred to in this work as a citation and/or a potential source of further information does not mean that
the author or the publisher endorses the information the organization or Web site may provide or recommendations
it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or
disappeared between when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the
United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade
dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States
and other countries, and may not be used without written permission. SQL Server and Windows PowerShell are
trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. All
other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any
product or vendor mentioned in this book.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be
available in electronic books.
Contents
Introduction xxi
Chapter 1: What Is Windows PowerShell? 1
Command-Line Interfaces versus Graphical User Interfaces 1
Prerequisites for Installing Windows PowerShell 2.0 2
Installing the Microsoft .NET Framework 6
Installing Windows Remote Management 6
Installing Windows PowerShell 7
Launching Windows PowerShell 10
Using the Command console 11
Using All Programs 11
Using Start Run 11
Summary 13
Chapter 2: Windows PowerShell Command Types, Snap-ins, and cmdlets 15
PowerShell Command Types 16
Native Commands 16
PowerShell cmdlets 18
Shell Function Commands 19
Script Commands 20
Calling PowerShell cmdlets or Scripts from the Command Shell 22
PowerShell Snap-ins 23
Core 24
Host 25
PowerShell.Management 25
Security 26
Utility 27
Diagnostics 27
WsMan.Management 28
PowerShell cmdlet Syntax 28
Named Parameter 28
Positional Parameter 29
Command Chaining 30
Contents
Getting Help 31
Filtering 34
Sorting 38
Formatting 39
Summary 42
Chapter 3: Windows PowerShell Programming, Scripting,
Error Handling, and Debugging 43
PowerShell Scripts 44
PowerShell Variables 44
Arrays 48
Expressions 49
Operators 50
Conditional Expressions 52
IF Statement 53
Loop Construct 54
For Loop 55
While Loop 55
Do-While Loop 56
Do-Until Loop 56
Foreach Statement 57
Input 58
PowerShell Scripting 59
Text File As Input 62
Output 64
Writing to the Console 64
Writing to a File 65
Error Handling 67
Debugging 71
Summary 75
Chapter 4: Windows PowerShell Functions, Parameters, Sourcing,
Scopes, and User Profile 77
Functions 77
Arguments in Functions 78
Returning Values 80
Script Parameters 81
Sourcing 84
Variable Scope 85
xiv
Contents
Function Scope 87
User Profile 88
Transcripts 90
Summary 91
Chapter 5: Working with the File System, Registry, and Variables 93
Using Get-PSDrive and Get-PSProvider 93
Working with File System 95
Navigating the File System 96
Managing Files and Directories 98
Managing File Contents 106
Working with the Registry 108
Working with Variables 111
Automatic Variables 113
Preference Variables 115
User-Created Variables 116
Working with Environment Variables 121
Summary 122
Chapter 6: Working with Event Logs 123
Event Log Service 124
Event Viewer 125
Event Logs 125
Log Entry Types 128
Exporting the event logs 134
PowerShell cmdlets Related to event log 136
Summary 140
Chapter 7: Working with Windows Services and Processes 141
What Is a Windows Service? 141
Windows PowerShell and Windows Services 143
Get-Service 144
Stop-Service 146
Start-Service 148
Set-Service 150
Working with Windows Processes 151
Get-Process 153
Stop-Process 155
Summary 157
xv
Contents
Chapter 8: Working with WMI 159
Permission Issues and WMI 159
The WMI Model 161
Working with Event Log 164
Working with Services 170
Working with Processes 179
Working with Environment Variables 186
Working with the Registry 190
Summary 195
Chapter 9: WMI Provider for Configuratio Management 197
Managing SQL Server Services 198
Managing Client Network Protocols 203
Managing SQL Server Client Aliases 207
Managing Server Network Protocols 211
Changing FILESTREAM Settings 214
Changing SQL Server Advanced Properties 216
Summary 218
Chapter 10: WMI Provider for Server Events 219
WMI Provider for Server Events 219
WMI Query Language (WQL) 220
Event Handling with Windows PowerShell 2.0 221
Monitoring Errors from the SQL Server Error Log 225
Monitoring Deadlocks 226
Monitoring Blockings 229
Monitoring Login Changes and Failed Login Attempts 233
Monitoring Databases 235
Monitoring Database Objects 236
Summary 239
Chapter 11: Windows PowerShell in SQL Server 2008 Environment,
SQL Server PowerShell Provider 241
sqlps Utility 241
SQLSERVER: Drive and Invoke-Sqlcmd cmdlet 245
SQL Snap-ins 245
Encoding and Decoding Uniform Resource Name (URN) 256
Summary 258
xvi
Contents
Chapter 12: Managing Policies through SQLSERVER: SQLPolicy 259
SQLSERVER: SQLPolicy Folder 259
Conditions 263
Policies 268
Summary 281
Chapter 13: Windows PowerShell and SMO 283
PowerShell and the SQLConnection .NET Class 283
Working with SQL Server using SMO 290
Methods and Properties 291
Getting Version Information 291
SQL Server SPID Information 292
SQL Server Server-Related Information 293
SQL Server Database-Related Information 295
Changing the Login Mode 296
Host Information 296
Performance Counters 297
Working with Databases using SMO 297
Working with Tables using SMO 304
Creating Tables 305
Listing Columns 305
Removing Columns 306
Adding Columns 307
Dropping a Table 308
Backup and Restore with SMO 308
Database Backup 308
Transaction Log Backup 311
Differential Backup 312
Restoring Full Backup 313
Restoring a Full Backup and Transaction Log Backup 313
Summary 316
Chapter 14: Building SQL Server Standards and PowerShell
Coding Standards 317
SQL Server Standards 318
SQL Server Development Standards 318
Naming Conventions 318
General Rules 320
Stored Procedure Standards 321
Keep Them Small 321
‘‘DBO’’ As Object Owner 321
xvii
Contents
Use Comments Generously 321
Select * 322
Cursors 322
Temporary Tables 322
Things to Avoid 322
Things to Use 323
Check @@ERROR 323
Use SQL Server Date Data Types 323
DML Statements 323
ANSI-Standard Join Clauses 323
Deprecated Features 324
Database Design Standard and Best Practices 324
User-Define Tables 324
Logs 324
Split tempdb 325
Databases 325
Security and Roles 325
Auto Create and Auto Update 325
Size 325
Auto Shrink and Auto Close 325
Design and Performance 326
Store Unstructured Data 326
More Performance Guidelines 326
Data Protection Standards and Best Practices 327
Backup Policy 327
SQL Server Production Standards 327
High Availability and Disaster Recovery 327
The Administration Database 328
The Scratch Database 328
Centralized Inventory Server 328
Database File Location and RAID 328
Segregation 328
Features 328
PowerShell Coding Standard 329
Default Parameters 329
Log File 329
Log Format 329
Comments 330
Display 330
Variable Naming Convention 330
Exception Handling 330
Summary 331
xviii
Contents
Chapter 15: Building SQL Server Inventory 333
SQL Server Inventory 333
Hosts 335
Clusters 346
ClusterNodes 350
Servers 355
Databases 368
Supplementary Tables 373
Summary 376
Chapter 16: SQL Server Installation 377
Installation Procedure and Template 377
SQL Server Installation Template 381
Standalone Installation Example 389
Cluster Installation Example 395
Summary 399
Chapter 17: Collecting SQL Server Performance and Host
Performance Data 401
SQL Server Performance Data Collection 401
SQL Server Host Performance Data Collection 408
Summary 417
Chapter 18: Monitoring SQL Server 419
Pinging SQL Server Hosts 420
Checking SQL Server–related Services on SQL Server Hosts 423
Checking Uptime of SQL Server Hosts 427
Monitoring Windows Event Logs 429
Monitoring SQL Server Error Log 433
Monitoring Blockings 439
Monitoring Deadlocks 444
Summary 449
Chapter 19: Monitoring Disk Space Usage, Database Files, and Backups 451
Monitoring Disk Space Usage 451
Monitoring Database Files 461
Monitoring Backups 468
Summary 473
xix
Contents
Chapter 20: Definin Policies 475
Stored Procedure Naming Convention Policy 475
Auto_Close and Auto_Shrink Off Policy 480
Summary 485
Chapter 21: Generating Database Scripts 487
Scripting Databases 487
Scripting Schemas 489
Scripting User-Define Data Types 491
Scripting Tables 494
Scripting User Views 496
Scripting Stored Procedures 498
Scripting Functions 500
Scripting XML Schemas 502
Scripting Users 503
Summary 506
Appendix A: cmdlets 507
cmdlets Related to Core Snap-ins 507
cmdlets Related to the PowerShell Management Snap-in 512
cmdlets Related to the Security Snap-in 519
cmdlets Related to the Utility Snap-in 520
Index 531
xx
Introduction
Welcome to SQL Server 2008 Administration with Windows PowerShell. This book is a nuts-and-bolts guide
to creating Windows PowerShell scripts that can be used to administer every aspect of the SQL Server
2008 Database Engine. Using a very hands-on approach, this book guides you through the basics of
Windows PowerShell, the available Windows PowerShell components that have been integrated into
SQL Server 2008, and the actual administration tasks. By providing clear, well-structured examples, SQL
Server 2008 Administration with Windows PowerShell shows you how to construct effective and practical
solutions that can improve SQL Server administration and monitoring at your company.
SQL Server 2008 delivers a dynamic, smart, and productive data platform for all your data-related
needs. SQL Server 2008 offers secure, reliable, and consistent performance. It is also very scalable and
flexible, handling any form of data. It is well known in the technology world that SQL Server 2008 is not
only a RDBMS, but also has built-in features such as Integration Services for ETL, Analysis Services for
Business Intelligence, Reporting Services for report management, and more. This is why Microsoft SQL
Server is a cut above all other database products.
Windows PowerShell 2.0 is the new extensible command-line interface shell and scripting language that
provides an environment for interactive scripting and non-interactive scripted administration of local
and remote computers. Because Windows PowerShell integrates with the Microsoft .NET Framework,
we can take advantage of all the features of .NET as well. Windows PowerShell 2.0 helps system admin-
istrators to automate and manage various aspects of the Windows environment. PowerShell 2.0 also has
many new and useful features such as remoting, eventing, and many more. For these reasons, Windows
PowerShell 2.0 stands above all the system administration products on the market.
This book brings together the best of both worlds — namely, the database world and the administra-
tion world — to help you manage, automate, and control your environment. This book combines three
technologies — SQL Server 2008, the .NET Framework, and Windows PowerShell 2.0 — and guides SQL
Server database administrators in managing a server plant using Windows PowerShell 2.0.
We’ve provided a wide range of material in a tutorial-based book to get you over the learning curve of
Windows PowerShell 2.0 and SQL Server 2008 database administration.
Who This Book Is For
Whether you are a SQL Server database administrator, a developer, or a systems administrator, at some
point you probably have had to develop or administer the system or the database in your organization.
It is also common for the people in these roles to wear each other’s hats in order to get things done.
If you are a Microsoft SQL Server database administrator, you know that you cannot manage and access
all the system resources from SQL Server. Because SQL Server runs on top of the Windows operating
system and relies on the health of the system, you need information from the system side as well. This
book will teach you to manage both SQL Server and system resources using Windows PowerShell 2.0.
Introduction
If you are a systems administrator and would like to know more about SQL Server database adminis-
tration, this book introduces you to the features in SQL Server 2008 and provides plenty of examples
demonstrating how to manage SQL Server 2008 using Windows PowerShell 2.0.
This book is also appropriate for those who have some exposure to systems administration and SQL
Server administration, or for those who want to expand their skill set to include administration.
What This Book Covers
This book covers the fundamentals of Windows PowerShell 2.0 cmdlets. It includes programming, script-
ing, debugging, and error handling in PowerShell. It covers all Windows administration related to SQL
Server 2008 using Windows PowerShell 2.0.
It also introduces Windows Management Instrumentation (WMI) and explains how to write WMI scripts
in Windows PowerShell to perform system and SQL Server 2008 administrative tasks.
This book also covers the WMI providers for SQL Server. These useful providers enable you to manage
SQL Server services and network connectivity, and proactively monitor SQL Server events. You will also
discover the new Eventing feature in Windows PowerShell 2.0.
Additionally, the new SQL Server 2008 support for Windows PowerShell is presented. It illustrates the
SQL Server PowerShell provider and SQLSERVER: drive. You will also learn how to manage SQL Server
objects, including the new policy objects.
One more important topic this book covers is using SQL Server Management Objects (SMO) to create
databases and tables and perform backups and restores. The SMO scripts shown in this book are all
written in Windows PowerShell 2.0.
This book also explains the need for SQL Server standards; and you will learn how to build a SQL Server
inventory over an existing or new environment.
Finally, you will learn how to perform the various SQL Server administrative tasks on servers in the
inventory, such as installation, monitoring, performance data collection, policy definition, backups,
restores, database scripting, and more, using Windows PowerShell 2.0.
How This Book Is Structured
Windows PowerShell 2.0 is introduced in the first eight chapters. If you do not have any background
in Windows PowerShell 2.0, these chapters are critical. They help you understand the basics of writing
Windows PowerShell 2.0 scripts, and you will learn how to use the scripts to administer the overall
operating system.
Chapter 1 covers installation of prerequisites, and installation and configuration of Windows
PowerShell 2.0.
Chapters 2, 3, and 4 cover the various cmdlets available in Windows PowerShell, and the various pro-
gramming features such as inputs, outputs, debugging, error handling, functions, profiles, and so on.
xxii
Introduction
Chapters 5, 6, 7, and 8 cover the various systems administration features, including accessing file systems,
registry information, variables, and Event logs. It also explains the Windows Management Instrumenta-
tion (WMI) model and shows you how to use WMI to manage system resources.
Chapters 9 and 10 show you how to access the WMI providers for SQL Server. You will learn how to use
the WMI Provider for Configuration Management to manage SQL Server services and network connec-
tivity, and the WMI Provider for Server Events to manage SQL Server events. You will also discover the
new Eventing feature in Windows PowerShell 2.0.
Chapters 11 and 12 take on the Windows PowerShell support that has been integrated into SQL Server
2008, namely, the SQLSERVER: drive. These two chapters will focus on the SQL and SQLPolicy folders
separately.
Chapter 13 shows you how to write SQL Server Management Objects (SMO) programs in Windows
PowerShell 2.0. This chapter covers various tasks such as creating a database and database objects, and
backing up and restoring a database.
Chapters 14 and 15 provide you with ample examples of building a SQL Server tasks inventory over an
existing or new environment, and how to define various standards. Standards include both SQL Server
standards and Windows PowerShell standards.
The remaining chapters explain installation, data collection, monitoring, and how to create Windows
PowerShell scripts to handle a wide range of SQL Server administrative tasks for servers in the inventory.
Chapter 16 illustrates the installation of SQL Server 2008. Chapter 17 covers tasks related to collecting
SQL Server host and server performance data. Chapters 18 and 19 cover monitoring aspects of SQL
Server 2008 administration. Chapter 20 defines policies to enforce SQL Server standards, and Chapter 21
generates various scripts at both the database level and the database object level.
What You Need to Use This Book
This book covers SQL Server 2008 administration with Windows PowerShell 2.0. In order to use this
book, you need both a server-side component and client-side components:
❑ For the server-side component, you need SQL Server 2008 Developer or Enterprise or Standard
edition.
❑ For client-side components, you need Windows PowerShell 2.0 CTP3. To install Windows
PowerShell 2.0 CTP3, the operating system of your computer needs to be either Windows XP
Service Pack 3, Windows 2003 Service Pack 2, Windows Vista Service Pack 1, or Windows Server
2008. You also need to pre-install the following components on your computer:
❑ Microsoft .NET Framework 2.0 or greater
❑ Windows Remote Management 2.0 CTP3 for Windows PowerShell remoting and back-
ground jobs
We discuss the prerequisites of Windows PowerShell 2.0 in Chapter 1 in detail.
xxiii
Introduction
All the scripts and codes in the book have been tested on SQL Server 2008 with .NET Framework 3.5
and Windows PowerShell 2.0 CTP3. We tested all the scripts on Windows XP, Windows Server 2008,
and Windows Vista. Most of the scripts and code illustrated here work under Windows PowerShell
1.0 as well, although you may notice that the output of such scripts and codes differs slightly, and that
remoting under Windows PowerShell 1.0 is not possible unless you use WMI objects.
In order to install Windows PowerShell 2.0 and Windows Remote Management, and to store all the
scripts provided in the book, you need a minimum of 100MB of hard disk space.
Conventions
To help you get the most from the text and keep track of what’s happening, we’ve used a number of
conventions throughout the book.
Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this.
As for styles in the text:
❑ We highlight new terms and important words when we introduce them.
❑ We show filenames, URLs, and code within the text like so: persistence.properties.
❑ We present code like this:
We use a monofont type with no highlighting for most code examples.
Source Code
As you work through the examples in this book, you may choose either to type in all the code manually or
to use the source code files that accompany the book. All of the source code used in this book is available
for download at www.wrox.com. Once at the site, simply locate the book’s title (either by using the Search
box or by using one of the title lists) and click the Download Code link on the book’s detail page to obtain
all the source code for the book.
Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is
978-0-470-47728-1.
Once you download the code, just decompress it with your favorite compression tool. Alternately, you
can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see
the code available for this book and all other Wrox books.
Errata
We make every effort to ensure that there are no errors in the text or in the code. However, no one is
perfect, and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or a
faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may save
xxiv
Introduction
another reader hours of frustration, and at the same time you will be helping us provide even higher
quality information.
To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one
of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all
errata submitted for this book and posted by Wrox editors. A complete book list, including links to each
book’s errata, is also available at www.wrox.com/misc-pages/booklist.shtml.
If you don’t spot ‘‘your’’ error on the Book Errata page, go to www.wrox.com/contact/techsupport.
shtml and complete the form there to send us the error you have found. We’ll check the information and,
if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the
book.
p2p.wrox.com
For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based
system for you to post messages relating to Wrox books and related technologies and interact with other
readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of
your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts,
and your fellow readers are present on these forums.
At http://p2p.wrox.com you will find a number of different forums that will help you not only as you
read this book, but also as you develop your own applications. To join the forums, just follow these steps:
1. Go to p2p.wrox.com and click the Register link.
2. Read the terms of use and click Agree.
3. Enter the required information to join as well as any optional information you wish to pro-
vide and click Submit.
4. You will receive an e-mail with information describing how to verify your account and com-
plete the joining process.
You can read messages in the forums without joining P2P but in order to post your own messages, you
must join.
Once you join, you can post new messages and respond to messages other users post. You can read
messages at any time on the Web. If you would like to have new messages from a particular forum
e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing.
For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to
questions about how the forum software works, as well as many common questions specific to P2P and
Wrox books. To read the FAQs, click the FAQ link on any P2P page.
xxv
What Is Windows
PowerShell?
Windows PowerShell is the extensible command-line interface shell and scripting language that
provides a command-line environment for interactive exploration and administration of computers.
In addition, it provides developers with an opportunity to script these commands, enabling them
to be automated, scheduled, and run multiple times.
This chapter covers the following topics:
❑ A brief overview of command-line interfaces
❑ Prerequisites for installing PowerShell
❑ Installing PowerShell 2.0 CTP3.
Command-Line Interfaces versus Graphical
User Interfaces
Before UNIX, Linux, and Windows surfaced in the information technology market, input media
such as punched card and punched tape were used. All the input and instructions to the computer
used command lines.
When UNIX and Linux were released, administrators started managing the operating system using
command-line interfaces, which were also used by the day-to-day users and programmers to inter-
act with the operating system.
UNIX and Linux are built on command-line interfaces, so there has always been administrative
scripting and different shells, such as the Korn shell, the C shell, and the Bourne shell. Programming
languages such as TCL and PERL were immediately available.
Chapter 1: What Is Windows PowerShell?
Originally, when Microsoft released MS-DOS, it was not used as a shell. It was entirely a standalone
operating system. The initial and original Microsoft Windows release was a graphical shell that sat on
top of the MS-DOS operating system. Once Windows NT was introduced, this situation was reversed.
MS-DOS became the shell in the graphical Windows operating system.
Graphical user interfaces (GUIs) were basically developed for users with less technical background who
were looking for a friendly interface. Because graphical interfaces are limited to fewer functions, once
you hit their limitations you will start relying on the command-line interface. For example, with a GUI,
if you want to rename all the extensions of a group of files and suffix each file with the current day’s
timestamp, it will take a while because you have to select and rename each file individually.
Therefore, command-line interfaces and their commands are very commonly used for administrative
tasks and automation. They also help to consolidate functionality in batches, through MS-DOS batch
files.
command.com was used as the command-line user interface in early versions of Microsoft Windows.
cmd.exe was introduced in Windows NT.
When administrators reached the limit of command-line batch files, they started looking for a language
that could do both command shell functions and programming. Microsoft introduced the Visual Basic
scripting language, which helped administrators initially. However, there were limitations in VBScript as
well. Administrators started relying on Windows Management Instrumentation (WMI) and COM objects
introduced later by Microsoft for many other administrative functions.
The administrative command-line interface started becoming more complicated with internal DOS com-
mands, external DOS commands, batch files, executables, VBScripts, WMI, and so forth.
It was with all of this in mind that Microsoft developed and introduced Windows PowerShell.
Prerequisites for Installing Windows
PowerShell 2.0
Windows PowerShell can be installed and run on Windows XP, Windows Vista, Windows Server 2003,
and Windows Server 2008. Although Windows PowerShell is included as part of Windows Server 2008,
it is not installed by default on Windows XP, Windows 2003, or Windows Vista. At the time of writing,
Windows PowerShell 1.0 is visible as a feature in Windows Server 2008 that can be turned on.
Windows PowerShell 1.0 is also installed with Exchange Server 2007, System Center Operations Manager
2007, System Center Data Protection Manager V2, and System Center Virtual Machine Manager because
they leverage Windows PowerShell to improve administrator control, efficiency, and productivity.
This book uses Windows PowerShell 2.0 CTP3. Before installing Windows PowerShell 2.0 CTP3, you
should ensure that your system has the following software programs it requires:
❑ Windows XP Service Pack 3, Windows 2003 Service Pack 2, Windows Vista Service Pack 1, or
Windows Server 2008
❑ Microsoft .NET Framework 2.0 or greater
2
Chapter 1: What Is Windows PowerShell?
❑ Windows Remote Management 2.0 CTP3 for Windows PowerShell remoting and background
jobs
❑ Microsoft .NET Framework 3.5 Service Pack 1 for Windows PowerShell Integrated Scripting
Environment (ISE) and the Out-GridView cmdlet
If .NET Framework 2.0 is not installed on your computer, the error message shown in Figure 1-1 will pop
up when you try to install Windows PowerShell 2.0 CTP3.
Figure 1-1
After installing the .NET Framework, if you continue to install on a non-standard operating system such
as Windows Server 2000, Windows NT, and so on, you may get the error shown in Figure 1-2.
Figure 1-2
Although Figure 1-2 shows v1.0 in the title bar and file path, it is actually PowerShell 2.0 CTP3. Com-
munity Technology Preview, also known as CTP3, is basically the bug fix that Microsoft relies on, adding
new features based on feedback from the technology community. The folder may be changed to v2.0 once
the release to manufacturing (RTM) version is released.
In order to check the prerequisites for the PowerShell installation, we created a batch file to run all the
necessary checks. Listing 1-1 shows the MS-DOS batch script, CheckPowershellPreqs.bat, which uses
Windows Management Instrumentation Command-line (WMIC) to check the requirements before you
install Windows PowerShell. WMIC enables you to access WMI information via the command line. In
some respects, you can think of WMIC as an early prototype of PowerShell. However, WMIC can only
output its results as text. It doesn’t return programming objects that can be further processed, as Window
PowerShell does, and as you will see later.
Listing 1-1: CheckPowershellPreqs.bat
@ECHO Off
REM *****************************************************************
REM *Objective: TO check if the current windows version is *
REM * Compatible for PowerShell 2.0 and its pre-requisites*
REM *Created by: Yan and MAK *
REM *Created Date: 2008/09/01 *
Continued
3
Chapter 1: What Is Windows PowerShell?
Listing 1-1: CheckPowershellPreqs.bat (continued)
REM * *
REM *****************************************************************
SET OS_VERSION=
SET Service_Pack=
REM Find OS version
FOR /F "delims== tokens=2" %%i IN (’wmic os get Version /value’)
DO SET OS_VERSION=%%i
IF NOT DEFINED OS_VERSION (
ECHO WMIC is not installed on this system.
GOTO :END_SCRIPT
)
REM Find service pack value
FOR /F "delims== tokens=2" %%i IN (’wmic os get ServicePackMajorVersion /value’)
DO SET Service_Pack=%%i
REM Windows XP
IF "%OS_VERSION%"=="5.1.2600" (
@IF "%Service_Pack%" LSS "3" (
ECHO %OS_NAME% Service Pack 3 is required
GOTO :END_SCRIPT
)
GOTO :DOTNETFRAMEWORK_CHECK
)
REM Windows Server 2003
IF "%OS_VERSION%"=="5.2.3790" (
@IF "%Service_Pack%" LSS "2" (
ECHO %OS_NAME% Service Pack 2 is required
GOTO :END_SCRIPT
)
GOTO :DOTNETFRAMEWORK_CHECK
)
REM Windows Vista
IF "%OS_VERSION%"=="6.0.6001" (
@IF "%Service_Pack%" LSS "1" (
ECHO %OS_NAME% Service Pack 1 is required
GOTO :END_SCRIPT
)
GOTO :DOTNETFRAMEWORK_CHECK
)
IF "%OS_VERSION%" GTR "5.2.3790" (
GOTO :DOTNETFRAMEWORK_CHECK
)
ELSE (
GOTO :END_SCRIPT
)
4
Chapter 1: What Is Windows PowerShell?
Listing 1-1: CheckPowershellPreqs.bat (continued)
REM Check .NET framework
:DOTNETFRAMEWORK_CHECK
wmic product where (caption like "Microsoft .NET Framework%%") get Version /value |
findstr "=[2-9].*" > nul
IF "%ERRORLEVEL%"=="1" (
ECHO .NET Framework 2.0 or greater is required
GOTO :END_SCRIPT
)
REM Check Windows remote management
:WINRMCHECK
wmic path Win32_service where caption="Windows Remote Management (WS-Management)" |
findstr /i "(WS-Management)" > nul
IF "%ERRORLEVEL%"==1 (
ECHO Windows Remote Management is required
GOTO :END_SCRIPT
)
ECHO Your system meets the requirements
:END_SCRIPT
From a Windows command console, run CheckPowershellPreqs.bat from the script directory
C:DBAScripts. You should get a message similar to the one shown in Figure 1-3 if your system meets
the requirements for a PowerShell installation.
Figure 1-3
You may run into an error as follows on Windows Server 2003:
ERROR:
Code = 0x80041010
Description = Invalid class
Facility = WMI
This means that you need to install the WMI Windows Installer Provider in order for WMIC to work.
To do so, open Control Panel  Add/Remove Programs. Select Add/Remove Windows Components.
Double-click Management and Monitoring Tools. Select WMI Windows Installer Provider, and then click
OK to install.
If your operating system is Windows XP Service Pack 2 and you install Windows PowerShell 2.0 CTP3, it
may or may not work. The officially supported service pack for Windows XP when installing Windows
5
Chapter 1: What Is Windows PowerShell?
PowerShell 2.0 CPT3 is Service Pack 3, so when executing C:DBAScriptsCheckPowershellPreqs.bat
it will complain that Service Pack 3 is required.
Installing the Microsoft .NET Framework
Windows PowerShell integrates with the .NET Framework and provides a shell environment to per-
form administrative tasks. PowerShell exposes the .NET classes as built-in commands, and when these
commands are executed they produce one or more structured objects as output.
Download the .NET Framework from http://download.microsoft.com and install .NET Framework 2
or later. It is recommended that you use .NET 3.5, although all the code in this book works on .NET
Framework 2 and later. In Chapter 11, you will see that an SQL Server 2008 installation installs .NET 3.5
by default.
Installing Windows Remote Management
Another prerequisite is to install Windows Remote Management (WinRM). WinRM is required for Win-
dows PowerShell remoting and background jobs. You can download WinRM 2.0 CTP3 (also known as
Ws-Management) from https://connect.microsoft.com/WSMAN/Downloads for Windows Vista and
Windows Server 2008. The installation procedures of the executable Windows6.0-KB950099-x86.msu for
32-bit and Windows6.0-KB950099-x64.msu for 64-bit are shown in Figure 1-4 and Figure 1-5.
Figure 1-4
Figure 1-5
6
Chapter 1: What Is Windows PowerShell?
Double-click on Windows6.0-KB950099-x86.msu if you are installing WinRM on a 32-bit Windows oper-
ating system. Double-click on Windows6.0-KB950099-x64.msu if you are installing it on a 64-bit Windows
operating system.
If you already have Windows PowerShell 1.0 installed on your machine, then you have to uninstall
PowerShell 1.0 first and then install PowerShell 2.0 CTP3.
To uninstall Windows PowerShell 1.0, follow these steps:
1. Click Start ➪ Run, type appwiz.cpl, and then click OK.
2. Select the Show Updates check box (on the top in the middle).
3. In the list of currently installed programs, click Windows PowerShell(TM) 1.0, and then click
Remove. If you don’t see Windows PowerShell(TM) 1.0, please look for Windows Hotfix
926139, 926140, or 926141.
4. Follow the instructions to remove Windows PowerShell(TM) 1.0.
If you already have Windows PowerShell 2.0 CTP1 or CTP2, you have to uninstall them also. They
appear as ‘‘Windows PowerShell V2 (TM)’’ in the program list.
In Windows 2008, Windows PowerShell 1.0 is made visible as a Windows feature. You can disable and
uninstall the PowerShell feature as described here:
1. Click Start at the Windows taskbar.
2. Click Server Manager  Features  Add Feature, and uncheck the Windows PowerShell
check box.
3. Click Next to uninstall.
Now that you have the acceptable operating system, the .NET Framework, and Windows Remote Man-
agement, the next section provides the steps needed to actually install Windows PowerShell 2.0 CTP3.
Installing Windows PowerShell
To install Windows PowerShell on Windows XP or Windows 2003 systems, do the following:
1. Download the Windows PowerShell 2.0 CTP3 installation file from www.Microsoft.com/
downloads. The name of the installation file varies according to platform, operating system,
and language pack. Choose the appropriate version for your operating system. If you have a
64-bit Windows operating system, then please download PowerShell_Setup_amd64.msi, as
shown in Figure 1-6. If you have a 32-bit Windows operating system, then please download
PowerShell_Setup_x86.msi, as shown in Figure 1-7.
2. After downloading the appropriate version for your operating system, you will see the ini-
tial screen of the installation wizard, similar to the one shown in Figure 1-8. Click Next.
3. Accept the license agreement, as shown in Figure 1-9, and click Next.
7
Chapter 1: What Is Windows PowerShell?
Figure 1-6
Figure 1-7
Figure 1-8
8
Chapter 1: What Is Windows PowerShell?
Figure 1-9
4. It takes a few minutes to complete the install. As shown in Figure 1-10, click Install to begin
the installation process. You will see the progress of the installation, as shown in Figure 1-11.
Figure 1-10
5. When installation is completed successfully, you will see a screen similar to the one shown
in Figure 1-12. Click Finish.
On 32-bit versions of Windows, Windows PowerShell is installed by default in the %SystemRoot%
System32WindowsPowerShellv1.0 directory.
On 64-bit versions of Windows, a 32-bit version of Windows PowerShell is installed in the
%SystemRoot%SystemWow64WindowsPowerShellv1.0 directory and a 64-bit version of Windows
PowerShell is installed in the %SystemRoot%System32WindowsPowerShellv1.0 directory.
9
Chapter 1: What Is Windows PowerShell?
Figure 1-11
Figure 1-12
This book covers Windows PowerShell 2.0 CTP3. The installation file replaces the executables in the v1.0
folder. The actual folders for Windows PowerShell may change to v2.0 when PowerShell 2.0 RTM is
released.
Launching Windows PowerShell
Windows PowerShell can be launched in several ways. This section describes the different methods. No
method is superior to the others. It is just a matter of preference.
10
Chapter 1: What Is Windows PowerShell?
Using the Command console
To launch Windows PowerShell using the command console, open the command console and then type
powershell, as shown in Figure 1-13.
Figure 1-13
Using All Programs
You can also click Start  All Programs  Windows PowerShell V2 (CTP3), and then select and click
Windows PowerShell V2 (CTP3), as shown in Figure 1-14.
Figure 1-14
You may also see Windows PowerShell ISE (CTP3) in the Windows Program menu. The Windows Power-
Shell Integrated Scripting Environment (ISE) is a host application for Windows PowerShell. In Windows
PowerShell ISE, you can run commands and write, test, and debug scripts in a single Windows graph-
ical user interface. This book illustrates all Windows PowerShell-related cmdlets and scripts using a
command-line interface. It does not illustrate PowerShell scripts using the ISE.
Once PowerShell is launched, you can see the command prompt. The prompt in the PowerShell com-
mand window varies according to the operating system used.
To be consistent with the PowerShell window title, you could update the shortcut, as illustrated in
Figure 1-15. Right-click on the Windows PowerShell V2 (CTP3) shortcut, click Properties, and under
the General tab, update the title to ‘‘Windows PowerShell’’ and click OK.
Using Start Run
You can also launch PowerShell by clicking Start  Run and typing the following: %systemroot%
system32windowsPowerShellv1.0PowerShell.exe. Then click OK, as shown in Figure 1-16.
11
Chapter 1: What Is Windows PowerShell?
Figure 1-15
Figure 1-16
Alternatively, you can also launch PowerShell by clicking Start  Run and typing PowerShell.
Windows finds the PowerShell.exe executable from the environment PATH variable and then
launches it.
This opens the PowerShell command console, shown in Figure 1-17.
Figure 1-17
12
Chapter 1: What Is Windows PowerShell?
If you are using 64-bit PowerShell, then you can launch PowerShell by clicking Start  Run and typing
the following: %systemroot%SysWOW64WindowsPowerShellv1.0PowerShell.exe. Then click OK, as
shown in Figure 1-18.
Figure 1-18
This opens the PowerShell command console, as shown in Figure 1-19.
Figure 1-19
Summary
This chapter discussed the prerequisites for Windows PowerShell, described how to install Windows
PowerShell 2.0 CTP3, and showed various methods to launch PowerShell.
The next chapter covers the various command types and commonly used cmdlets that appear throughout
the book. A Windows PowerShell cmdlet is a simple command used for interaction with any managed
application, including the Windows operating system and applications such as SQL Server, Microsoft
Exchange, and so on.
13
Windows PowerShell
Command Types, Snap-ins,
and cmdlets
Now that you’ve installed Windows PowerShell on your computer, I bet you can’t wait to start run-
ning your own commands to unravel the power of Microsoft’s new command shell. This chapter
introduces you to the new PowerShell commands, or cmdlets. It also introduces you to the collec-
tions of cmdlets called snap-ins. By following all of the examples in this book, you will become
comfortable working with the cmdlets, and you will even be able to tweak the output to your
liking. First, however, this chapter gives you a quick-start on how to run PowerShell commands
interactively.
This chapter covers the following topics:
❑ PowerShell command types
❑ PowerShell snap-ins
❑ Syntax of cmdlets
❑ Command chaining
❑ Getting help
❑ Filtering
❑ Sorting
❑ Formatting
Chapter 2: Command Types, Snap-ins, and cmdlets
PowerShell Command Types
When you launch a new PowerShell window, you are basically executing a small PowerShell.exe
executable, which provides a command-line interface and issues instructions on how to make the func-
tionality in the PowerShell Engine available.
Those instructions are written in .NET language and are available in the form of commands called cmdlets
(pronounced ‘‘command lets’’). All the cmdlets, when executed, process the instructions and return an
object, not just text.
The following four different command types are available in the PowerShell environment. Don’t panic.
PowerShell understands and performs the different types of functions based on the type of commands
that you execute.
❑ Native commands
❑ PowerShell cmdlets
❑ Shell functions
❑ Script commands
The following sections take a closer look at the differences between the different command types in
PowerShell and how each can be used.
Native Commands
Native commands are external executables that the Windows operating system can run. For example,
notepad.exe, calc.exe, or even a batch file can be run from the PowerShell command-line interface.
The following example executes a Windows command shell cmd.exe with the system.ini file as a
parameter, as shown in Figure 2-1:
cmd /c c:windowssystem.ini
Figure 2-1
Once this command is executed, PowerShell recognizes the executable file and passes the command
to the operating system directly. The operating system basically opens the file using the default editor
Notepad.exe, as shown in the Figure 2-2.
If the default editor on your machine is not Notepad.exe, then the operating system opens this exe-
cutable file with your default editor, rather than Notepad.exe.
16
Chapter 2: Command Types, Snap-ins, and cmdlets
Figure 2-2
The next example will launch the Windows calculator. Enter the following command into PowerShell, as
shown in Figure 2-3:
calc
Figure 2-3
Once this command is executed, PowerShell recognizes the executable file and passes the command to
the operating system directly. The operating system launches the calculator, as shown in Figure 2-4.
Figure 2-4
You can also execute a batch file within the Windows PowerShell environment. Create a small batch file,
C:Batch-Test.bat, that displays the current date and time, as shown here:
@Echo off
Echo The current date is : %date%
Echo The current time is : %time%
17
Chapter 2: Command Types, Snap-ins, and cmdlets
You can execute the batch file in the Windows PowerShell environment using . or ./, as shown in
Figure 2-5:
.Batch-Test.bat
Figure 2-5
PowerShell cmdlets
PowerShell cmdlets are compiled DLL files that are loaded into PowerShell at runtime. Anybody
can write custom cmdlets using the PowerShell Software Development Kit (SDK). You can get more
information on the PowerShell SDK from http://msdn.microsoft.com/en-us/library/ms714469
(VS.85).aspx.
The cmdlets are constructed in verb-noun format. The verb specifies the action that it is going to perform
and the noun specifies the object being operated on. The noun is always singular (not plural), even if it
retrieves or acts on multiple objects.
The following example is a cmdlet that gets all the processes running on the current host machine, as
shown in Figure 2-6:
Get-Process
Figure 2-6
The term get in this command is the verb, and the term process is the noun, so the cmdlet ‘‘gets’’ all the
‘‘processes’’ running on the current host.
Amazing, isn’t it? You don’t have to use VBScript to query the WMI win32 process class and get the
process information and format the result. Just a simple Get-Process command will do that for you.
18
Chapter 2: Command Types, Snap-ins, and cmdlets
We know this makes you wonder what other amazing cmdlets are available that you could use in your
environment. If you would like to know the basic definitions of cmdlets and other elements of all the
PowerShell commands in the current PowerShell environment, you can run the following cmdlet, as
shown in Figure 2-7:
Get-Command
Figure 2-7
Figure 2-7 shows the names of the cmdlets and their definitions.
Windows PowerShell 2.0 CTP3 also has a feature called Tab Completion. With this feature, you don’t
have to type the entire cmdlet every time it is used. You can just type the beginning of the cmdlet — for
example, Get-PS, and press the Tab key. PowerShell will automatically complete your cmdlet with the
cmdlet starting with Get-PS. If more than one cmdlet starts with Get-PS, then press the Tab key again
and PowerShell will show you the next available cmdlet that starts with Get-PS. Continue pressing the
Tab key until you see the cmdlet that you want to use.
For example, if you type Get-PS and press the Tab key several times, all of the following cmdlets will
appear, in ascending order:
❑ Get-PSBreakpoint
❑ Get-PSCallStack
❑ Get-PSDrive
❑ Get-PSProvider
❑ Get-PSSession
❑ Get-PSSessionConfiguration
❑ Get-PSSnapin
Shell Function Commands
Shell function commands are subroutines that you can create and have available throughout the current
PowerShell session. If a block of code is often re-used in the main code, then you can create a function
and call the function wherever necessary within the main code.
19
Chapter 2: Command Types, Snap-ins, and cmdlets
Here is an example of how to create a simple function. This function lists all the files with the extension
.ini under the C:Windows folder. Shell functions are discussed in more detail in Chapter 4.
function list-ini {Get-ChildItem c:windows*.ini}
Once the preceding command is executed (see Figure 2-8), the function list-ini is created.
Figure 2-8
This list-ini function can be called anywhere in the current session. Execute the function as shown
in Figure 2-9. Once the function name is called, PowerShell recognizes it as a function code block and
executes the code block defined in the actual function list-ini. The following command requests all the
files with the extension .ini under C:Windows folder:
list-ini
Figure 2-9
Functions can be made persistently available in all the Windows PowerShell sessions by adding them to
the PowerShell profile. You will see examples of the Windows PowerShell profile and its uses in detail in
Chapter 5.
Script Commands
Script commands are a set of executable PowerShell cmdlets stored in a file with the .ps1 extension.
You can create a simple Add-Num.ps1 script using Notepad under the directory C:DBAScripts, as shown
in the following example. This script file, shown in Figure 2-10, accepts two variables, $variable1 and
$variable2, as parameters and stores the sum to a third variable, $variable3. It then displays the value
of $variable3.
# ==================================================
#
# NAME: Add-Num.ps1
20
Chapter 2: Command Types, Snap-ins, and cmdlets
#
# AUTHOR: Yan and MAK
# DATE : 4/26/2008
#
# COMMENT: This script accepts two numbers, sums the
# two numbers and display the result
#
# ==================================================
param (
[int] $variable1,
[int] $variable2
)
$variable3=$variable1+$variable2;
$variable3
You can use any text editor to write a PowerShell Script file, not just Notepad.
Figure 2-10
Here, all the information that appears after the pound symbol (#) will be ignored by Windows PowerShell
because that tells PowerShell that those are comments. Beginning with PowerShell 2.0 CTP3, you can use
multi-line comments using # and #.
Because you created the PowerShell script Add-Num.ps1 under C:DBAScripts, you have to navigate
to the folder DBAScripts. The cmdlet Set-Location can be used to move the location from the current
folder to the DBAScripts folder, as shown in Figure 2-11.
Then the PowerShell script Add-Num.ps1 can be executed using . or ./, as shown in Figure 2-11.
Set-Location C:DBAScripts
.add-num.ps1 100 200
./add-num.ps1 10 200
When executing the script, if PowerShell returns the warning message ‘‘Script cannot be loaded because
execution of script is disabled,’’ then execute the following command, followed by the script shown in
21
Chapter 2: Command Types, Snap-ins, and cmdlets
Figure 2-11
Figure 2-12. By default, execution of any PowerShell script is restricted for security reasons, but you can
use the cmdlet set-executionpolicy to make it unrestricted.
Set-ExecutionPolicy Unrestricted
Figure 2-12
More PowerShell scripts and securities are shown in detail in later chapters.
Calling PowerShell cmdlets or Scripts from the Command
Shell
PowerShell functionality can be used from other shells such as command shell. The PowerShell.exe
executable accepts numerous parameters, such as a console file or a command.
You can execute .ps1 files by passing them as parameters to the PowerShell executable, as shown in
Figures 2-13 and 2-14. Launch the command shell by running the following command from Start  Run,
as shown in Figure 2-13:
cmd.exe
At the command prompt, execute the following command as shown in Figure 2-14. This PowerShell.exe
executable accepts the parameter name -command and the parameter value Add-Num.ps1 with parameters
100 and 400:
PowerShell -command C:DBAScriptsadd-num.ps1 100 400
22
Chapter 2: Command Types, Snap-ins, and cmdlets
Figure 2-13
Figure 2-14
You can execute a PowerShell cmdlet directly from the command shell as shown here and in Figure 2-15:
PowerShell -command Get-Process
Figure 2-15
PowerShell Snap-ins
PowerShell cmdlets are contained in PowerShell snap-ins. PowerShell snap-ins are a group of Power-
Shell cmdlets or providers that extend the functionality of the shell. When a snap-in is loaded into the
PowerShell environment, the cmdlets and providers contained in it are registered with the shell.
By default, seven core snap-ins are loaded, and their corresponding cmdlets are available when Power-
Shell is launched. Each core snap-ins has its own namespace:
❑ Core
❑ Host
23
Chapter 2: Command Types, Snap-ins, and cmdlets
❑ Management
❑ Security
❑ Utility
❑ Diagnostics
❑ WSMAN.Management
Execute the following PowerShell cmdlet to see all the snap-ins that are loaded into the current Power-
Shell environment, as shown in Figure 2-16.
Get-PSSnapin
Figure 2-16
The following sections describe each of the snap-ins and their cmdlets. Most of the cmdlets listed here are
described and demonstrated throughout the remaining chapters. The following section provides basic
information about how to get all the cmdlets available in each snap-in.
You can also check Appendix A for more details about each cmdlet in each snap-in.
Core
The namespace of the Core snap-in is Microsoft.PowerShell.core. This snap-in contains cmdlets related
to the PowerShell engine, such as aliases, environments, variables, and functions.
You can find all the cmdlets available in the namespace Microsoft.PowerShell.core using the simple
cmdlet shown in Figure 2-17.
24
Chapter 2: Command Types, Snap-ins, and cmdlets
Here, two cmdlets are used. One is Get-Command, which provides the commands available in Power-
Shell. The other is Where-Object, which is used for filtering the result. The pipe (|)is used for command
chaining. More about command chaining is explained later in this chapter.
Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match core}
Figure 2-17
Host
The namespace of the Host snap-in is Microsoft.PowerShell.Host. This snap-in contains cmdlets related
to hosting, such as start-transcript and stop-transcript.
You can find all the cmdlets available in the namespace Microsoft.PowerShell.host using the following
cmdlet, shown in Figure 2-18:
Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match host}
Figure 2-18
PowerShell.Management
The namespace of the Management snap-in is Microsoft.PowerShell.Management. This snap-in contains
cmdlets related to windows management, such as managing services and processes, and so on.
25
Chapter 2: Command Types, Snap-ins, and cmdlets
You can find all the cmdlets available in the namespace Microsoft.PowerShell.Management using the
following cmdlet, shown in Figure 2-19:
Get-Command –commandtype cmdlet | Where-Object {$_.PSSnapin -match
PowerShell.Management}
Figure 2-19
Security
The namespace of the Security snap-in is Microsoft.PowerShell.Security. This snap-in contains cmdlets
related to PowerShell security, such as Get-Acl and Set-ExecutionPolicy.
You can find all the cmdlets available in the namespace Microsoft.PowerShell.Security using the follow-
ing cmdlet:
Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match Security}
Figure 2-20 shows some of the commonly used cmdlets, including their descriptions, related to the Secu-
rity snap-in.
Figure 2-20
26
Chapter 2: Command Types, Snap-ins, and cmdlets
Utility
The namespace of the Utility snap-in is Microsoft.PowerShell.Utility. This snap-in contains cmdlets that
can retrieve and manipulate data, such as write-host, Format-List, and so on.
You can find all the cmdlets available in the namespace Microsoft.PowerShell.Utility using the following
cmdlet:
Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match Utility}
Figure 2-21 shows some of the commonly used cmdlets, including their descriptions, related to the Utility
snap-in.
Figure 2-21
Diagnostics
The namespace of the Diagnostic snap-in is Microsoft.PowerShell.Diagnostics. This snap-in contains
cmdlets related to performance counters and event logs.
You can find all the cmdlets available in the namespace Microsoft.PowerShell.Diagnostics using the
following cmdlet, shown in Figure 2-22:
Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match Diagnostics}
Figure 2-22
27
Chapter 2: Command Types, Snap-ins, and cmdlets
WsMan.Management
The namespace of the WsMAN.Management snap-in is Microsoft.WsMan.Management. This snap-in
contains cmdlets related to WsMan.
You can find all the cmdlets available in the namespace Microsoft.WsMan.Management using the follow-
ing cmdlet, shown in Figure 2-23:
Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match
WsMan.Management}
Figure 2-23
cmdlets related to WsManagement are very new and currently there is little documentation for Power-
Shell 2.0 CTP3. This should change, however, after its official release. Such documentation, when it
becomes available, will help you understand more about each of the cmdlets and enable you to explore
their functionality and usage.
PowerShell cmdlet Syntax
As stated earlier in this chapter, cmdlets are constructed in verb-noun format. The verb specifies the action
to be performed and the noun specifies the object being operated on. Recall that the noun is always
singular, even if it retrieves or acts on multiple objects or data.
Two examples are the cmdlet Get-process and Write-host.
Most cmdlets accept parameters. All parameters names are prefixed with a hyphen, and all the parameter
values are prefixed with a blank space after the parameter name. There are two types of parameters:
named parameters and positional parameters.
Named Parameter
This is the easiest and most common way to use parameters. Basically, you specify the name of the
parameter followed by its value — for example, Get-Process –Name smss:
Get-Process –Name smss
28
Chapter 2: Command Types, Snap-ins, and cmdlets
Get-process is the cmdlet, Name is the parameter name, and smss is the parameter value.
Parameter values can be substituted with wildcards as well, as shown here and in Figure 2-24:
Get-Process –Name s*
Figure 2-24
Positional Parameter
PowerShell allows us to omit the parameter name completely for certain parameters. In the previous
example, name is a positional parameter in the first position; therefore, it can be called without the param-
eter name (see Figure 2-25), as shown here:
Get-Process s*
Figure 2-25
You can easily find all the positional parameter of a PowerShell cmdlet by executing the following cmdlet
(see Figure 2-26):
(Get-Help Get-Process).parameters.parameter
29
Chapter 2: Command Types, Snap-ins, and cmdlets
Figure 2-26
Figure 2-26 shows the end of the output. As you can see, the value of the Position? property of the Name
parameter is 1, so Name is a positional parameter at position 1.
Windows PowerShell supports the following six common parameters on all the cmdlets:
❑ Debug
❑ ErrorAction
❑ ErrorVariable
❑ OutputBuffer
❑ OutputVariable
❑ Verbose
Two other commonly used parameters available in certain cmdlets provide options for ‘‘what if’’ scenar-
ios and choosing confirmation (Yes/No):
❑ WhatIf
❑ Confirm
For more information regarding the common parameters, run the following command:
Get-Help about_CommonParameters
Command Chaining
As in UNIX and Linux, PowerShell cmdlets can be chained together using a pipeline. Command chaining
is having the output of one command feed into, or act as the input to, another command. This was shown
earlier in Figure 2-23.
In the following command example, the output of Get-Process is fed to the cmdlet Where-Object. The
output of the cmdlet Where-Object is fed to the cmdlet Sort-Object.
As you already know, the cmdlet Get-Process shows all the processes on the current local machine.
When the output of the Get-Process is fed to Where-Object using command chaining, the Where-Object
processes each item from the output of Get-Process and looks for the processname equal to the value
30
Chapter 2: Command Types, Snap-ins, and cmdlets
rundll32. Then the filtered output of Where-Object is passed to Sort-Object, which sorts the database
based on the Object ID value in descending order (see Figure 2-27).
Get-Process | Where-Object {$_.Processname -eq rundll32} | Sort-Object ID –desc
Figure 2-27
Hence, the output shown in Figure 2-27 is the result of command chaining. You will be using command
chaining throughout this book.
Getting Help
Microsoft documented all the cmdlets and that documentation can be retrieved using the cmdlet Get-
Help. This documentation is similar to using the man command in the UNIX and Linux environment. In
addition, certain parameters can be used with Get-Help to get detailed information and examples.
The cmdlet Get-Help can be used in three different ways:
❑ Get-Help with no parameter:
Get-Help Get-Process
This provides the minimal information needed to understand and use the cmdlet. The following
information is returned when executed (see Figure 2-28):
❑ Name
❑ Synopsis
❑ Detailed Description
❑ Related Links
❑ Remarks
❑ Get-Help with the –detailed parameter:
Get-Help Get-Process –detailed
31
Chapter 2: Command Types, Snap-ins, and cmdlets
Figure 2-28
This returns the following information when executed (see Figure 2-29):
❑ Name
❑ Synopsis
❑ Syntax
❑ Detailed Description
❑ Parameters
❑ Examples
❑ Remarks
Figure 2-29
❑ Get-Help with the –full parameter:
Get-Help Get-Process –full
This provides all of the following (see Figure 2-30):
❑ Name
❑ Synopsis
32
Chapter 2: Command Types, Snap-ins, and cmdlets
❑ Syntax
❑ Detailed Description
❑ Parameters
❑ Input Types
❑ Return Type
❑ Notes
❑ Examples
❑ Related Links
Figure 2-30
When using the -full and -detailed parameters, the documentation expands to several pages and
flashes through screen and it is very difficult to read all of them if you do not have enough screen buffer.
You can use command chaining with the MS-DOS executable more to page the documentation, as shown
here:
Get-Help Get-Process -Full | more
This causes the output to be displayed one screen at a time. You can scroll the pages from one screen
to another by pressing the spacebar or Enter key. You can abort the display of paging using Ctrl + C.
Figure 2-31 shows the same Get-Help Get-Process cmdlet using more.
Figure 2-31
33
Chapter 2: Command Types, Snap-ins, and cmdlets
Alternatively, you can just use the built-in Help function. The Help function actually pipes the result
from the Get-Help cmdlet to more to support paging, as shown in the following example:
Help Get-Process -Full
Filtering
The cmdlets can produce humongous results. Not all of the columns and rows that are displayed as
output are useful all the time. You may need to filter the results. PowerShell provides two cmdlets for
filtering: Where-Object and Select-Object.
As shown earlier when you ran the Get-Process cmdlet, it returns all the processes running on the
current host (see Figure 2-32):
Get-Process
Figure 2-32
If, for example, you’re only interested in the processes that start with ‘‘s’’, then you can use the Where-
Object cmdlet as shown here and in Figure 2-33:
Get-Process | Where-Object {$_.Processname -like s*}
Figure 2-33
34
Chapter 2: Command Types, Snap-ins, and cmdlets
Basically, $_ is substituted with the actual output of Get-Process row by row and evaluated against the
–like operator with the value s*.
If you want to list all the processes that start with ‘‘s’’ excluding the process name svchost, then you can
use the and and ne operators in the Where-Object, as shown here (see Figure 2-34):
Get-Process | Where-Object {$_.Processname -like s* –and $_.Processname –ne
svchost }
Figure 2-34
The following table shows the comparison operators available in PowerShell.
Comparison Operator Meaning Example (returns true)
-eq Is equal to 1 -eq 1
-ne Is not equal to 1 -ne 2
-lt Is less than 1 -lt 2
-le Is less than or equal to 1 -le 2
-gt Is greater than 2 -gt 1
-ge Is greater than or equal to 2 -ge 1
-like Is like (wildcard comparison for text) file.doc -like f*.do?
-notlike Is not like (wildcard comparison for text) file.doc -notlike p*.doc
-contains Contains 1,2,3 -contains 1
-notcontains Does not contain 1,2,3 -notcontains 4
-ceq Case sensitive equal to a -ceq a
-cne Is not equal to a -cne A
35
Chapter 2: Command Types, Snap-ins, and cmdlets
The next table shows the logical operators available.
Logical Operator Meaning Example (returns true)
-and Logical and; true if both sides are true (1 -eq 1) -and (2 -eq 2)
-or Logical or; true if either side is true (1 -eq 1) -or (1 -eq 2)
-not Logical not; reverses true and false -not (1 -eq 2)
! Logical not; reverses true and false !(1 -eq 2)
You can also filter items up front in the Get-Process itself, as shown here and in Figure 2-35:
Get-Process s* | Where-Object {$_.Processname -ne svchost}
Figure 2-35
If the operator needs to use numerical values, then you can use numerical operators, as shown here and
in Figure 2-36:
Get-Process | Where-Object {$_.Handles -gt 1100 -and $_.CPU -gt 5}
Figure 2-36
36
Random documents with unrelated
content Scribd suggests to you:
Vai sillä tavalla! Voi sentään, etten minä juopporaukka ole kyllin
hyvä lähestymään sellaista Jumalan enkeliä! —
Lapikas-Pekka kääntyi äkkiä lapsista, ja palasi yksin tyhjään, mutta
nyt niin siistiin tupaansa. Hän istui takan ääreen ja nyyhkytti niinkuin
kaikki elämänilo olisi häneltä paennut.
Halli, joka oli tyytyväisenä nähnyt vastenmielisen seuran lähtevän
tiehensä ja ulkona pikkuportaalta iloisesti heiluttanut jäähyväisiä
hännällään, vinkui nyt surkeasti ja osaaottaen tavatessaan isännän
tuvassa niin raskaalla mielellä.
Seitsemäs luku.
HAJALLAAN.
Lapsijoukon kulku suuren tunturikylän läpi ei herättänyt erikoisen
suurta huomiota väestössä. Liiankin usein nähtiin näinä aikoina
kokonaisten nälistyneitten perhekuntienkin lähtevän kerjäämään
elatustaan.
Hallantunturin lapset vaelsivat Lapikas-Pekan neuvosta suoraan
virran partaalle päin. Aluksi he olivat pelokkaita ja allapäin ja
puhuivat kaipauksella silmälasimiehestä.
Mutta oli sentään niin ihanaa, kun oli paljon lunta, ja niin vapaata
ja hauskaa oli päästä ulkoilmaan, että he lopullisesti tunsivat itsensä
oikein tyytyväisiksi ja hilpeiksi aamurupeamassa. Ilma selkeni, ja
kinokset seisoivat korkeina valleina pitkin tien syrjää. Nuo raskaat
kinokset olivat niin lystikkään näköisiä. Ne olivat ripustautuneet
kattojen päälle kuin paksut, valkoiset vällyt, jotka riippuivat vasten
ikkunoita. Katajilla ja pikkukuusilla oli latvassaan korkeita, hupaisia
piippalakkeja, ja pitkin vanhoja aitoja laskeutuivat kinokset kuin
paksut, valkovillaiset vaatteet. — Niin, että olipa paljon hauskaa
nähtävää tänäpäivänä.
Punaisista kaksikerroksisista taloista ja pienistä, harmaista tuvista
he eivät niin paljoa välittäneet. Niissä oli kaikki jotenkin
samannäköistä kuin kotona omassa pitäjässä. Naisväki kahlasi polvia
myöten lumessa päästäkseen navettoihin, jotka olivat vaipuneet
valkoisiin kinoksiin; lapset lakaisivat ja lapioivat portaita ja polkuja, ja
miehet askaroitsivat ajokaluineen ja valmistautuivat metsälle
hirrenajoon.
Puolipäivään päästessä menivät lapset ison kylän päässä olevaan
suurtaloon. Ruokaa he saivat siellä, leipää ja keitettyä silakkaa.
Astiallinen kirnupiimää pantiin myös heidän eteensä uuninpenkille.
Mutta he läksivät sieltä äänettöminä ja alakuloisina. Emäntä, joka
oli heille Jumalan lahjan antanut, oli näyttänyt niin tuimalta,
heittänyt ruuan heille ja mutissut — mutta niin että kaikki kuulivat —
että tunturilta tulevat kerjäläiset söivät kohta koko talon
putipuhtaaksi. Isäntä, joka oli tullut sisään ja nähnyt heidän syövän
rivissä uuninpenkin ääressä, oli sanonut, että tuollainen joukko sopisi
parhaiten köyhäintaloon, ja että elleivät hänen hevosensa olisi kiinni
metsäajoissa, tekisi hän viisaimmin toimittaessaan heille paluukyydin
sinne. Talon lapset olivat näyttäneet niin jöröiltä ja happamilla kuin
olisivat asuneet köyhäinhuoneella sen sijaan että elivät suuressa
talossa, missä oltiin niin rikkaita, että siellä hyllyllä oven päällä oli
kuusi kuparikattilaa, ja koreita kaappeja ja kokonainen rivi
hopealusikoita ylinnä kaapinhyllyllä.
Vaikka siellä oli hienoa, oli Pekan tuvassa mielestäni koreampaa,
sanoi Mauno. Kas se oli mies, se.
Koreampaa ei ollut, väitti Anna-Liisa. Olikos sekin laitaa miten
kamalalta siellä näytti tullessamme: lattia likainen ja takka musta, se
ei tainnut olla vuosikausiin valaistu, ja ikkunanlasi niin ettei läpi
näkynyt, ja lakanat ja pieluksen päälliset ylen ruskeita, ennenkuin
saimme ne pestyiksi. Ei, koreampaa ei siellä ollut. Nytkään ei siellä
ole koreampaa, vaikka lattia on valkoinen, ja matot lattialla, ja takka
hieno, ja ikkunanlasi kirkas, sikäli kuin minä ymmärrän.
Anna-Liisa katseli epätietoisen ja hämmästyneen näköisenä
eteensä.
Niin, en minäkään ymmärrä, tunnusti Antti. Me saimme heidän
luonansa leipää paremmista jauhoista, ja valoisaa ja koreaa siellä oli,
ruokaa me saimme, ja kumminkin olen aivan kuin kiukuissani heille.
Äiti sanoi, ettemme saisi olla kiukuissamme, Antti. Ei, en minä ole
vihainen, sanoi Matleena, mutta kun ajattelen heitä, niin oikein
pelkään ihmisiä, joiden luo meidän pitää joutua pitäjällä. Minä
pelkään sellaisia, joilla on suurtaloja. Heillähän kuuluu olevan
kuitenkin kaikki niin hyvin, rahaa kun on, millä ostaa, niin ettei
nälkävuosi pysty heihin.
Pekan luona on kuitenkin parempi olla.
Sisarukset kävelivät ryhmässä Antin ympärillä. Heillä oli niin paljon
juttelemista ja tuumaamista.
Ja siellä ei kuitenkaan ollut äitiä ollenkaan, siellä Pekan talossa,
huomautti Mauno.
Ei, sillä silloin hänellä kai olisi ollut siistimpää nurkissaan, —
ratkaisi Anna-Liisa.
Jos se äiti olisi ollut sellainen kuin meidän äiti, ennenkuin hän
kuoli, lisäsi Matleena luoden katseensa ylöspäin.
Ei niillä itselläänkään ollut yhtään hauskaa.
Meidän pitää kiiruhtaa, että pääsemme joen yli, ennenkuin tulee
pimeä, sanoi Antti katsahtaen ympärilleen. Koillisesta rupeaa
vinhasti tuulemaan, eikä se ole koskaan mikään hyvä tuuli.
Kuinkas pikkutytöt nyt voivat? Antti pysähytti kelkan, kumartui
pikkutyttöihin päin ja tukki vällyn lujasti Martta-Eevan ympärille, joka
istui Sanna-Kaisan edessä vähän vinossa.
Taas lähdettiin matkaan vereksin voimin. Poissa olivat ajatuksista
jääkylmä suurtalo ja sen herättämät harmilliset tunteet. Tie oli
jotenkin hyvin ajettu. Sitäpaitsi oli peuralauma selvästi äsken
kulkenut siitä ja polkenut sen auki. Tuhannet jäljet olivat pitkin
matkaa tehneet tien leveäksi ja aukinaiseksi.
Punotuista juurista tehty rikkinäinen juustosammio, jollaisia
lappalaiset käyttävät valmistaessaan poronmaidosta juustoa, oli
keskellä tietä. Matleena otti sen ja asetti tietä osottavan pikkukuusen
oksalle. Tule ja anna sen olla, murisi Anna-Liisa.
Sen ei ollut siinä hyvä, ja pikkukuusi pyysi minua laittamaan
itsensä hienoksi, nauroi Matleena, mutta nyt minä alan väsyä.
Äänestä kuului, ettei Matleena ollut hetikään niin hilpeä kuin oli
olevinaan. Asetuhan hetkeksi anturoille, niin saat levätä, sanoi
Antti. Anna-Liisa ja minä tulemme kyllä teidän kaikkien kolmen
kanssa toimeen hyvän matkaa. Pelkään tuolla luoteessa,
suurtunturin yläpuolella, asustavaa lumipilveä. — Mutta ei kai
kestäne peräti kauvan, ennenkuin pääsemme joelta ja saavutamme
kylän, josta Pekka puhui. He kävelivät nopeasti eteenpäin sileää
tietä, joka kulki joella jään yli. Pikkutytöt olivat nukkuneet, ainakin
he olivat aivan ääneti. Vetäjätkin olivat vaiti. Ilmassa oli ikäänkuin
jotain pelottavan uhkaavaa.
Tuulenpuuska saavutti heidät pitkään ja valittavasti ulvahtaen:
Hui, voisi luulla sutten olevan perässämme, niin ilkeästi ääntelee
ilmassa, sanoi Anna-Liisa ja veti ohuen huivin paremmin päähänsä.
Sinun on kai sittenkin nyt helpompi kävellä, kun olet saanut
jalkoihisi jotain kunnollista? kysyi Antti katsahtaen tosin sangen
kömpelöihin, mutta kuitenkin uusiin, mainioihin lapikkaihin.
Sepä se vasta oli asia. Voin vaikka hypätä niissä, ja ne pysyvät
kumminkin jalassa. Anna-Liisa teki todellakin muutamia ei erikoisen
somia hypähdyksiä tietä pitkin.
Hän tunsi sillä perinpohjin ärsyttäneensä lumihiutalepilven, joka oli
väijynyt lasten tiellä. Sillä yhdessä vilahduksessa ennätti terävästi
pieksevä tuisku kietoa heidät ryöppyynsä. Se tunkeutui äkäisesti
vinkuen huivien ja saalinriekaleitten sisään. Se heittäytyi tukkuina
tien yli, joka muuttui pian epätasaiseksi, kulkien kuin aallonharjoissa.
Elleivät pikkukuuset olisi seisoneet tietä viitoittamassa, olisivat lapset
äkkiä eksyneet äärettömän aukealla, nyt umpeen pyryttyneellä
jokilakeudella.
Oli raskasta vetää kelkkaa kasaantuneen lumen halki. Antti huusi
Matleenalle, että hän sai nyt kiivetä pois anturoilta. Matleena totteli
ja tuli kohta kahlaten sisarusten luo, jotka vuohi keskellänsä
muodostivat tiheän ryhmän. Miten kelkka siinä samassa
keventyikään! Kovinpa olit raskas. Nyt se on köykäinen kuin tyhjää,
sanoi Anna-Liisa nykäisten itselleen nuoran. Hän oli tullut vallan kuin
toiselle mielelle saatuaan parempaa jalkoihinsa ja päästyään
karvastelevasta kengänhieromasta.
Minun mielestäni ei tässä lumessa oikein kykene pääsemään
eteenpäin, jupisi Mauno, joka oli juuri keskellä kinosta.
Mutta minä kuljen kinosten pohjia, minä, läähätti Pekka-Erkki,
siinä kyllä joutuu kulkemaan vähän edestakaisin, mutta minä en
totisesti jaksa alinomaa kahlata läpi.
Luuletko olevan vielä pitkältä kylään? kysyi Matleena kuiskaten,
pujottaen lujasti kätensä Antin toiseen käteen.
En, vastasi Antti, joka yritti pitää silmiään auki ja nähdä rajusti
tanssivien, piiskaavien lumihiutaleitten läpi.
Meidän täytyy pysähtyä ja tukkia ensin lujemmin peitteet
pikkutyttöjen ympärille, että saavat lämpöisempää, sitte kuljemme
nopeammasti.
Antti kääntyi kelkkaa kohden. Hänen mielestään se lumen
hohteessa näytti niin merkillisen tyhjältä. Parilla askeleella hän oli
sen vieressä. Hän päästi huudon, käheän, kummallisen. Sisarukset
eivät varmaan koskaan olleet kuulleet Antin niin huutavan, hänen,
joka aina pysyttäytyi hiljaisena ja totisena.
Mikä kumma sinua vaivaa, poika? huudahti Anna-Liisa.
Martta-Eeva —! Tottahan näette — Sanna-Kaisa, kuuletko sinä!
Antti puristi eloa Sanna-Kaisaan, joka nukkui sikeästi.
Missä on Martta-Eeva?
En minä tiedä, tättä te on yttäpäätä ittunut!
Voitteko nyt kulkea yksin eteenpäin, niin minä menen takaisin
Martta-Eevaa etsimään, sanoi Antti päättävästi. Kävelkää vain niin
nopeasti, että pysytte lämpiminä ja pysykää kuusenviittojen välissä.
Niin, teidän pitää tehdä niinkuin minä sanon, toisti Antti arvonsa
tuntevasti, mutta kovin murheellisen näköisenä, kun nyt kaiken
lisäksi sisarukset pelästyksestä päästivät surkean hätähuudon,
suruissaan ja kauhuissaan kun olivat, jäädessään yksin ilman Antin
turvallista suojaa.
Saattanet toki sinä, Anna-Liisa, pitää suusi kiinni, ja tekin, jotka
olette miesväkeä. Minun pitää mennä tietä pitkin takaisin ja etsiä
Martta-Eevaa. Hän vierähti varmaan kelkasta heti, kun Matleena oli
mennyt kannoilta. Etkö olisi saanut seisoa siinä, että olisit sen
nähnyt? Minunkin piti tietysti laiskotella, etten viitsinyt vetää niin
monta!
Niin, älä nyt sitä sure, nyyhkytti Matleena.
Mene ja hae meidän pieni Martta-Eeva. Me kuljemme eteenpäin
kuin aikaihmiset. Onhan meillä palanen sianlihaa syödäksemme ja
leipää myöskin.
Ota sinä lapset huostaasi, Anna-Liisa!
Ota osviittaa pienestä juustoseppeleestä kuusenoksalla; kun minä
panin sen sinne, olimme kaikki mukana, ja sen vuoksi ei sinun
tarvitse mennä sitä kauvemmaksi, huusi Matleena Antin jälkeen,
joka nyt puolijuoksua tuulen ja piiskaavan lumen takaa-ajamana lähti
kulkemaan umpeentuiskunutta lumikenttää.
Kahdeksas luku.
MINNE ON MARTTA-EEVA JOUTUNUT?
Anna-Liisa koetti saada Sanna-Kaisan vaikenemaan ja
rauhoittumaan jokeltavalla puheella ja uudella, lämpimällä
maitotilkalla. Pienin, nyt nuorin, tukittiin lujasti kelkkaan kiinni.
Matleena asettui täst'edes varmuuden vuoksi taakse työntämään.
Hän koetti pitää lumen huikaisemia silmiään auki voidakseen varoa,
ettei tämäkin piskuinen vierähtäisi pois ja katoaisi heiltä.
Antin kehotuksia vailla he lahnustivat hitaasti ja raskaasti kinosten
läpi väsyneinä, pelokkaina, nälkäisinä. He vaelsivat raskaassa
surussa Martta-Eevan tähden, joka oli ollut heille suureksi iloksi
lystikkäine puheluineen ja hauskoine vehkeineen. He unohtivat
aivan, miten väsyttävä hän myöskin oli ollut, kun hän oli huutanut
öisin ja tarvinnut hoitoa, vaatetusta ja ruokintaa, kantamista ja
askartelemista joka tavalla.
Minä ajattelin aina, ettei hän kauvan elä, sanoi Anna-Liisa
itkuisella äänellä.
Se minunkin mieleeni tuli, kun hän sanoi tahtovansa äitin luo
taanaan, lisäsi Matleena surullisen ja huolestuneen näköisenä kuin
vanha ihminen.
Niin, kunhan ei vain susi olisi häntä ottanut, huomautti Mauno
rikkiviisaalla vanhuksen äänellä, sudet ovat vaarallisia näin
talvisaikaan. Hallajärvellä niitä on ollut taloissa asti.
Poika kulta, ole vaiti, puhui Matleena. Pitääkö tässä kulkea ja
ajatella suden repineen pienen Martta-Eevan. Jos ei Antti löydä
häntä, on hän lentänyt 'taimaiteen taanaan', ja äiti on ollut
hakemassa hänet, vaikka me emme nähneet sitä tässä
lumentulvassa.
Eipä siitäkään voi olla varma, väitti Pekka-Erkki ajattelevasti
sylkäisten eteensä. Virtanen Pihlajavedellä kuuluu pelästyttäneen
karhun pesästään, ja nyt se tietysti kiertää ja juoksentelee ympäri
seutuja nälissään. Mesikämmen on varmaankin repinyt hänet.
Tottakai, matki Matleena Pekka-Erkkiä vinkuvalla äänellä.
Ja aina Pihlajavedeltä tänne asti, missä maailma melkein loppuu,
on karhu juossut syödäkseen meidän pienen Martta-Eevan. Väinö
Paukan isokarju on kai myöskin päässyt ulos ja saanut vihiä hänestä,
ja koulunopettajan vanha pässi on hänet vainunnut, saadakseen
puskea hänet kuoliaaksi.
Matleena rupesi itkemään. Te olette niin ilkeitä keksimään pahaa,
kun entuudestaankin jo on huonosti asiat, että — että minä suutun.
On kai kauniimpaa ajatella äidin lentäneen tänne noutamaan Martta-
Eevaa, joka oli hänelle niin rakas. Jos hän vain olisi jaksanut, olisi
hän kyllä ottanut Sanna-Kaisan myöskin.
Älä nyt rupea puhumaan sinäkin niinkuin sellainen, joka ei elä
kauvan, keskeytti Anna-Liisa sisaren harmin purkauksen. Minun
mielestäni meidän ei pidä ajatella mitään, ennenkuin saamme kuulla,
miten asia on, kun Antti tulee takaisin.
Hän ei löydä meitä koskaan, murisi Mauno.
Mutta Antti löysi kuitenkin. Hän tuli kömpien lumessa, kun
sisarukset olivat niin väsyneitä, niin menehtyneitä, etteivät enää
jaksaneet puhua eivätkä toisilleen vihoitella.
He eivät edes jaksaneet pistää kättänsä poveen tunnustellakseen
oliko yhtään leivänpalaa jäljellä niistä, joita he olivat sinne panneet.
Jos vain Anna-Liisa olisi pysähtynyt tai istuutunut kinokseen
lepäämään, olisi koko joukko seurannut hänen esimerkkiään,
pikkupojat kaikkein mieluimmin raskaissa, hankalissa vaatteissaan.
Helokki etupäässä esti heitä istuutumasta ja siten ijäksi nukkumasta.
Jos vain joku lapsista kääntyi siinä tarkoituksessa sivulle, juoksi se
tiehensä kova-äänisesti määkien. Ja sitte täytyi heidän kohta mennä
perästä, kun he niin pelkäsivät kadottavansa sen.
Mutta eivät he kauan jaksaneet siihenkään mukautua.
Mauno, joka oli pitkän aikaa horjahdellen kävellyt, kaatui,
kiukkuisesti sähisten, kun Anna-Liisa tahtoi auttaa häntä jaloilleen ja
saada hänet matkaan.
Niinpä oli kuin ihme, että Antti vihdoinkin tuli, sillä hänen kanssaan
tuli lapsiin taas elämää ja virkeyttä.
Hän tuli kuitenkin ilman pientä Martta-Eevaa —! Aina kuusessa
olevaan juustoseppeleeseen saakka oli hän kulkenut, mutta ei ollut
nähnyt jälkeäkään heidän pikkutytöstään.
Susi kyllä selviää siitä, mitä hän käsiinsä saa, huomautti Mauno
epäilevällä syrjämulkauksella Matleenaan, joka loistavin silmin
vakuutti, että silloinpa hän kuitenkin oli ollut oikeassa sanoessaan
äidin ottaneen Martta-Eevan taivaalliseen Kaanaaseen.
Aina susi toki olisi jättänyt jonkin vaaterievun, vakuutti hän
innokkaasti. Hoo — hän on kyllä kantanut hänet mukanaan täysissä
vaatteissa, väitti Mauno itsepintaisesti.
Mitä sinä luulet, Antti? sanoi Matleena ja hiipi pelosta väristen
veljen luo.
En tiedä. Koko matkan oli vain valkeata, yhteenajautunutta lunta.
Matleena, en siedä sitä ajatusta, että susi olisi repinyt pienen
Martta-Eevan. On niin raskasta — aivan kuin olisi se minun syyni.
Olisit ennemmin iloinen ja tuntisit mielesi keveäksi, sillä äiti on,
näetkös, ottanut pikkutytön kokonaan luokseen.
Et saa itkeä, Antti.
Matleena silitti veikon poskea jäästä kangistuneella lapasellaan,
mutta ei se häntä lohduttanut.
Suuri poika! Kyyneleet tippuivat sekoittuen kirvelevään lumipyryyn
hänen siinä kulkiessaan etukumarassa vetäen nyt lumisohjussakin
kuitenkin liian kevyttä kelkkaa. Hän tunsi tuskin helpotusta
tienhaaran näkyessä, joka johti joelta maalle. Ja vasta nyt huomasi
Antti, että lumimyrsky oli tauonnut ja että taivas illan tullen oli
kirkastunut.
Yhdeksäs luku.
TAIMAINEN TAANA.
Jahtimestari Hirvi matkusti kotiin samaa tietä, jota lapset olivat
edellisenä päivänä tallustaneet. Hän oli ajanut läheltä ohi heidän
pienen, harmaan tupansa Hallatunturilla, sivuuttanut suurmetsän ja
ollut kuten lapset pakoitettu rajuilman tähden jäämään ensimäiseen
tunturikylään.
Hän ei totisesti ajatellut majoittua silmälasimiehen luo, hän, vaan
oli asunut majatalossa ja syönyt hyvän aamiaisen hilpeässä
seurassa. Ja siten hän oli tullut lähteneeksi myöhään matkalle. Nyt
hän ajoi niemen kaltevaa, epätasaista tietä alas, jota lapsetkin
vast'ikään olivat menneet, saavuttaakseen joen ja sen poikitse
kulkevan tien. Hän istui pienessä kilpa-ajoreessään puettuna
sudennahkaturkkiin, karvaiseen lakkiin ja mainioihin
peurannahkasaappaisiin, jotka ulottuivat polvien yläpuolelle.
Pieksevä pyry ei häntä suuresti vaivannut, varsinkin kun tuuli pian oli
muuttuva sivulliseksi.
Jahtimestari aikoi oikaista ja valita tien, minkä ainoastaan Leivo,
hänen hevosensa, ja hän itse tunsivat, ja joka vei vinosti joen yli
harjua kohden isoon kirkonkylään, missä hänen kotinsa oli.
Juuri tullessaan erään uloimpana niemellä kasvavan
käkkärämännyn kohdalle, missä tie kulki, ja missä hänkin oli pannut
merkille oikopolun, säikkyi Leivo ja hyppäsi molemmin etujaloin
varovasti jonkin yli, joka makasi keskellä lumen ahtamaa tietä. Sitte
ei hevonen hievahtanut paikaltaan, käänsi vain päänsä katsoen
isäntään. Jahtimestari hypähti notkeasti kilpa-ajoreestä. Hän
kumartui hevosen alle. Taivaan Jumala, mitä tämä oli! Lapsi, yksin
tällaisessa autiossa seudussa, pieni raukka kalpein, itkusta kiiltävin
poskin, verhottuna köyhiin riepuihin.
Jahtimestari seisoi hetken neuvotonna lapsi sylissään. Nukkuiko
se, oliko se kuollut?
Ei, se eli — se hengitti, rupesi huutamaan. — Äiti — Antti —
Elotti —Anna-Aitta. Lapsi nyyhkytti ja huusi kylmästä väristen.
Nuori mies seisoi siinä tyhmänä ja neuvottomana. Nainut hän oli ja
koti hänellä oli. Mutta hänellä ei ollut pienintäkään tottumusta tai
kokemusta pienten lasten käsittelyssä, hänellä kun ei ollut koskaan
itsellään lapsia ollut.
Leivokin näytti ymmärtävän asian paremmin. Se kaapi
etukavioillaan lunta, heitteli päätänsä ja katsoi isäntäänsä. Mikä oli
yksinkertaisempaa kuin ottaa mukaan pieni ihmisvarsa, jonka hän oli
ollut polkea kuoliaaksi, ja vinhaa vauhtia lähteä sen kera kotiin,
missä se saisi lämmintä ja hoitoa.
Aivan kuin olisi käsittänyt hevosen ajatuksen kulun, ryhtyi
jahtimestari äkkiä toimeen. Hän otti pienen kirkujan ja pujahutti
hänet turkkinsa sisäpuolelle. Mutta jotenkin suurella
vastenmielisyydellä, sillä jahtimestari oli sangen hieno ja siro mies,
joka pelkäsi likaa ja riepuja ja ennenkaikkea kauhistui kirkuvia,
niistämättömiä tenavia. Ja tämä oli mitä suurimmassa määrässä
kirkuva ja äärimmäisessä niistämisen tarpeessa oleva lapsipoloinen.
Kas niin, nyt hänet oli köytetty tiukasti lämpimän turkin sisälle.
Lapsukainen vaikeni vähitellen reen keinuessa tiettömän lumen yli ja
umpikulkusten kauniisti kaikuvalla äänellä kilistessä. Sillä vaikka
olikin raskasta päästä lumen läpi, mennä viiletti Leivo kuitenkin
kaikin voimin. Olihan ehdittävä kotiin paleltuneen ihmislapsiraukan
kanssa.
Jahtimestari, joka ensin oli pitänyt pienokaista suorana edessään
kuin hirrenpätkää, kävi niin omituiseksi mieleltään, tuntiessaan
pienen, laihan ruumiin värisevän vähitellen heikkenevistä
nyyhkytyksistä. Miten hyvältä tuntuisikaan voida lohduttaa ja auttaa
sellaista pientä. Hän asetti hänet turkissa parempaan asentoon.
Mitähän ruuan puolta sellainen pienokainen tarvitsi? Jumala
vahvistakoon minua totisesti, ajatteli hän. Kaikesta ruuasta ja
juomasta, jota olen itseeni tänä aamuna ajanut, ei minulla nyt ole
pienintä leipäkannikkaakaan jäljellä tällaiselle pikkuruiselle. Saat
kiiruhtaa, tyttöseni, kehotti hän hevosta.
Leivo päristelihe ja nosti päätään. Eikö hän muka ollut kiirehtinyt
rajua lumimyrskyä vastaan, joka repi sekä harjaa että häntää, ja
kahlannut lumessa välistä vatsaa myöten. Mutta eipä sillä, saattoi
hän kyllä vieläkin lisätä vauhtia, jos niiksi tuli. Niin, hän voisi juosta
itsensä pilallekin, juosta, kunnes paikalle kaatuisi, jos isäntä niin
tahtoisi! Isäntä, jota hän oli palvellut kymmenen vuotta ja yhdessä
hänen kanssaan kulkenut metsät ja tunturit.
Tie, joka kulki suuren metsän läpi ja jolle he nyt saapuivat, oli
ajettu. Leivo lähti pyyhältämään, niin että kulkusvyö helähteli.
Illansuussa oli hän ennättänyt suureen tunturipitäjään, joka levisi
tuolla puolen laajan laaksonpohjukan. Sitte riennettiin ylös
aikamoista mäkeä. Sinne johti valkorunkoisten koivujen muodostama
kuja. He ajoivat sitä pitkin ja pyöräyttivät lopuksi pieneen,
vaaleanpunaiseksi maalattuun taloon, jonka parveke ja kuistikko
olivat vihreät ja valkoiset. Tuli loisti akkunoista, ja savupatsas kohosi
suorana ilmaan, joka nyt oli kuulakkaa ja kirkasta ja johon
ruusunpunainen iltarusko ja vähitellen ilmestyvät tähdet valoivat
hohtoaan.
Tervetuloa kotiin, Artur, huusi nuori rouva parvekkeelta. Hän
seisoi siellä suureen villasaaliin kietoutuneena, jonka sisältä hänen
hienot kalpeat kasvonsa ja vaalea tukkansa pilkistivät.
Kiitos, muijaseni! Pyydä, että Tuovi tulee ottamaan minulta
tuomiseni.
Tuovi, vanha palvelijatar, joka oli aikoinaan hoitanut jahtimestarin
rouvaa, kun tämä oli ollut lapsi, saapui hyväntuulisena alas portaita.
Välistä tapahtui nimittäin, että jahtimestarilla oli muassaan jotain
harvinaista syötävää tai muuta, karhunpaisti, sudennahka tai
tavallisimmin monenlaisia lintuja. Niin että Tuovi oli valmistautunut
saamaan suuren sylyksen. Mutta hän vetäytyi pelästyneenä takaisin.
No mutta, hyvä jahtimestari! Mitäs me tuollaisella? Menkää
sisään, rouva, te vilustutte.
Mutta silloin kuului reestä parkaisu, lohduton, hyljätyn pikkulapsen
huuto. Nuori rouva heitti pois saalin. Hän juoksi alas portaita
muutamin askelin, otti kirkuvan riepukäärön syliinsä ja kantoi sen
ylös. Lapsukainen — pieni raukka, mitä he ovat sinulle tehneet?
Hiljaa, hiljaa nyt. Pääsemme pian lämpimään ja saamme ruokaa
pieneen ruumisparkaan.
Kerttu rouva ei pelännyt kirkuvia, niistämättömiä tenavia. Hän oli
kyllä tottunut pikkulapsiin vanhempainsa kodissa, missä heitä oli
ollut iso sisarusparvi. Hänellä ei itsellään ollut ainoatakaan lasta
syväksi, salaiseksi surukseen. Hänen miehensä ei hyväksynyt hänen
toivoansa saada ottaa kasvatti. Hän ei nimittäin tahtonut, että he
ottaisivat edesvastuulleen toisten lapsia, ja kärsi jo ajatellessaankin
häijyjä, tottelemattomia, kirkuvia, likaisia tenavia — muunlaisia
lapsia hän ei voinut mielessään kuvitellakaan. Ja nyt hän oli itse
kuljettanut pienen lapsen taloon!
Illalla syötyään ja levättyään istui jahtimestari ja katseli, miten
hänen vaimonsa nopeasti ja taitavasti muutti suuria vaatekappaleita
pieniksi, miten hän ihmeellisellä tavalla sai kokoon vaaleansinisen
pienen hameen, pienen esiliinan ja parin pieniä housuja. Hän oli niin
toimessaan, hänen pikku vaimonsa. Vaaleat hiukset kihartuivat
otsalle, ja muuten niin kalpeille poskille oli työ ja työninto nostanut
hienon punerruksen. Hän katsahti mieheensä loistavin silmin.
Artur, mehän pidämme hänet vastaiseksi? Saat nähdä hänet. Hän
makaa
Tuovin kamarissa, suuressa vaatekopassa, mihin hänelle on tehty
vuode.
Hän saanee jäädä, kunnes se ilmestyy, jolla on häneen oikeus.
Emmehän voi heittää häntä maantielle. Ihme, etteivät sudet, joita
täällä näinä päivinä on liikkunut, siepanneet häntä.
Huu, ja sinähän ammuit vasta toissa päivänä kaksi sellaista
otusta. Voi, jospa ei kenelläkään olisi oikeutta häneen! Hänen
nimensä lienee Marjatta, sillä hän nimittää itseään 'Atta-Eetaksi'. Hän
on niin suloinen. Ja tiedätkö, hän risti kätensä kohta, kun oli saanut
velliä ja voileipää ja sanoi: 'tiitot tulle', ja hän juttelee niin somasti.
Niin, kyllähän sen tietää, mitä tuollainen puolenvuoden vanha
tenava tai mitä hän nyt lienee, saattaa jutella.
Rakas, hän on paljon yli puolen vuoden, hänellähän on suu
täynnä pieniä, valkeita hampaita, ja hän käveleekin niin somasti.
Varmaan hänellä on hyvä äiti.
Toivon sitä lapsen itsensä vuoksi, jos hän kerran tulee takaisin
hänen luokseen.
Oi, ei — Artur. Emme me laske häntä pois!
Hänellä lienee ainakin sisar tai jokin muu hyvä ystävä, jonka nimi
on Voilokki, ja jolla on tapana antaa hänelle maitoa, sillä saadessaan
heti tultuaan maitoa, hän huusi yhtä päätä: 'Elotti'. 'Anna-Aitta',
sanoo hän myöskin usein. Ymmärrän hyvästi lapsen kieltä ja arvaan
hänen tarkoittavan 'valkeata kissaa'. Huomenna koetan saada käsiini
valkean kissan. Päästessään sänkyyn, kun olimme saaneet
lämpimiksi hänen pienet, paleltuneet jalkaraukkansa, risti hän taas
kätensä ja lauloi, tiedätkö, oikein puhtaalla äänellä, niin sievän
sävelmän.
Sanoineen päivineen? kysyi jahtimestari hiukan ivallisesti, vaikkei
hän huomattavasti huvitettuna saattanut olla kuuntelematta
vaimonsa selityksiä.
Sanoineen, se on tietty, mutta en voi selittää, mitä ne
merkinnevät.
Lakkaamatta hän lauloi samaa sanaa niin suloisesti, pää kallellaan:
'Taimainen taana'.
Voi — 'Kankaiden hanhet'. Sitä laulua äitini lauloi minulle lapsena
ollessani, kun minun piti nukkua, laulua 'kankaiden hanhista'. Siitä
laulusta uskon oppineeni metsää ja kankaita niin rakastamaan, että
minusta tuli metsämies.
Eikö ole merkillistä, että tuo pieni, köyhä lapsukainen ylämaan ja
katovuoden surkeimmilta seuduilta tulee tänne luoksemme
laulamaan laulua, jota kuunnellessasi sinä, alamaan lapsi, pienenä
nukuit. Entäs se, että sinä, jonka päähän ei koskaan ole pälkähtänyt
selittää lapsenkieltä, nyt heti ymmärsit, mitä hän laulaa. Siinä piilee
mielestäni aivan kuin jokin tarkoitus!
Niin, on se tosiaankin kummallista, sitä en kiellä, sanoi
jahtimestari sangen mielissään siitä, että hänen vaimonsa ymmärsi
antaa arvon hänen taidolleen selittää lapsenkieltä.
Jos ei kukaan tule takaisin vaatimaan pienokaista, niin kyllä hän
minun puolestani saa jäädä. Pahinta on sinun, jonka pitää hoitaa
häntä.
Minun! Voi, Artur, jos tietäisit, kuinka olen kaivannut pientä lasta!
Jahtimestari veti vaimonsa luokseen. Tiedätkö, välistä olen
minäkin kaivannut.
Hän läksi ulos viheltäen kankaiden hanhia. Sitä laulua hän ei
ollut laulanut kuin pienenä poikana.
Kymmenes luku.
NIIN HIENO TYTTÖNEN.
Kahdeksan päivää myöhemmin tulivat lapset hitaasti taivaltaen
laahustavin, väsynein askelin mäentörmää ylös vaaleanpunaista taloa
kohden, missä jahtimestari asui. Tehtiin siten mutka suurelta
maantieltä ja sen varrella sijaitsevista taloista, niin ettei oikeastaan
kumpikaan, ei Antti eikä Anna-Liisa, olleet sen puolella. Kenties he
eivät saisi vaivainsa palkaksi tuskin leipäpalaakaan. Niin paljon
katovuoden väkeä oli läpi talven vaeltanut ennen heitä, minne ikänä
he tulivatkin, että saattoi ymmärtää ihmisten väsyvän antamaan.
Mutta Matleenan mielestä näytti siltä, kuin mäellä oleva
vaaleanpunainen talo olisi ollut puolukoilla ja kermalla sivelty, ja että
se ikäänkuin nauroi ja vilkutti heille pikku ikkunoineen, jotka
näyttivät katon alta tirkisteleviltä silmiltä.
Helokki oli samaa mieltä kuin Matleena. Se kääntyi jyrkästi
metsäkumpua kohden johtavalle tielle ja rupesi melkein juoksemaan,
niin että lasten enempää miettimättä täytyi seurata sitä.
He kävivät, kuten tavallista, hiljaisiksi ja aroiksi saapuessaan
taloon. Suuri, harmaa hirvikoira, joka haukkui, ei kuitenkaan
säikähdyttänyt heitä. Se näytti pikemmin arvokkaalta ja uljaalta kuin
kiukkuiselta. Lapset ohjasivat askeleensa keittiön puolelle ja asettivat
kelkan ulkosalle. Tällä kertaa he aikoivat antaa Pekka-Erkin jäädä
Helokin luo.
Kesken kaiken ja ennenkuin lapset olivat ehtineet sisälle, näkivät
he nuoren, hienon rouvan liukuvan kelkalla pihan perukassa
sijaitsevaa lyhyttä mäkeä alas. Pieni tyttö oli kelkassa hänen
edessään. Pienokainen oli puettu valkoiseen vohlannahkaturkkiin,
pieneen, valkoiseen, kudottuun lakkiin, ja jaloissa oli hänellä pienet
lapikkaat. Hän nauroi ja hypähteli rouvan polvella huomattavasti
riemuissaan kelkalla ajamisesta. Rouva nousi, nosti hänet syliinsä ja
suuteli häntä.
Rakas pieni Atta-lapsi, nyt käymme sisälle, lapsen pitää syödä ja
nukkua päivällistä ja tulla äidin terveeksi, reippaaksi tytöksi.
Elotti, Elotti, Antti, Anna-Aitta — Alleena.
Pienokainen pyristelihe kiivaasti irroittuakseen käsivarsista, jotka
hellästi ympäröivät häntä.
Kerttu rouva kääntyi nopeasti. Hän päästi lapsen, joka innokkaasti
juoksi hänen tyköään, ja antoi käsivartensa vaipua, seisoen hiljaa
paikallansa surun ja yksinäisyyden valtaamana. Lapset olivat kuin
kivettyneitä. He seisoivat hiiskahtamatta, liikkumatonna. Mutta
Helokki oli kohta asian perillä. Se päästi määkinän ja juoksi Martta-
Eevan luo. Mitäpä hän siitä huoli, että pienokainen oli, lapikkaita
lukuunottamatta, hieno kuin prinsessa. Sehän oli kuitenkin sama
pieni ihmisvohla, jolle hän oli antanut maitoa, ja jota hän oli
turkillaan lämmittänyt.
Elotti!
Martta-Eeva kiersi käsivartensa vuohen pään ympärille, joka taipui
häneen päin. Hän ojensi käsivartensa. Puttaa! Antti itä! Antti ota
Atta-Eeta!
Ja Antti otti syliin pikku siskon. Hän silitti hänen poskiaan, hänen
käsiään. Pikku tyttönen, — meidän pikku tyttömme! Sinä rakas
Martta-Eeva. Niin raskasta on meidän ollut ilman sinua. Martta-Eeva
piti käsivarsiaan hänen kaulassaan, niinkuin hän ei koskaan olisi
tahtonut päästää häntä. Mutta sitte tahtoivat toiset sisarukset saada
osansa, pieni Sanna-Kaisa ja kaikki muut olivat muodostaneet piirin
heidän ympärilleen ja nykivät jälleen löydettyä käsivarsista ja
sääristä saadakseen hekin hänet hyväilläkseen ja taputellakseen.
Martta-Eeva, heidän korea, hupainen pikku lapsensa, jota he olivat
niin suuresti ikävöineet! — Sama pikkutyttö, vaikka hän nyt oli
hienoissa herrasvaatteissa. He eivät laskeneet häntä, vaan tullessaan
keittiön kautta sisään kerjäämään oli heidän parvessaan pieni,
valkoisiin puettu, hyvin hoidettu lapsi.
Yhdestoista luku.
MOLEMMAT PIKKUTYTÖT.
Kun Hallatunturin lapset jälleen vaelsivat jahtimestarin talosta, oli
heitä enää vain viisi. Sanna-Kaisa oli saanut jäädä pikku siskon luo.
Ja niin olivat pikkutytöt taasen yhdessä. Jahtimestari itse oli niin
tahtonut. Järjestyksen ihmisenä hän huomasi ja hämmästyikin
äärettömästi ja ihmetteli, kun uusi, pieni ryppymekko, joka hänen
mielestään saattoi tuskin ymmärtää viedä ruokaa suuhunsa, tuli
hänen huoneeseensa kiittämään ruuasta ja heti huomasi hänen
paperiveitsensä pöydän alla. Pöydän alla on veitsi, piipitti hän
hienolla äänellä ryömien mainittua esinettä hakemaan. Ja totisesti,
paperiveitsi, jota hän, jahtimestari, niin varoi ja jota hän turhaan oli
etsinyt, oli hänen kirjoituspöytänsä alla melkein piilossa, poronnahan
peitossa.
Tahtoisitko antaa sen minulle, sanoi hän ojentaen kätensä.
Sanna-Kaisa astui heti esiin jättäen veitsen.
Jahtimestari, joka tiesi, miten vaikeata oli saada totutetuksi koiria
noutamaan esineitä, miltei nolostui. Hän oli luullut vielä
vaikeammaksi saada lasta tottelemaan.
Anna-Aitta tulee, uuti nutte, laulaa, toutaa — taimaan taana, uuti
nutte. Martta-Eeva, joka oli jo aivan kotiutunut jahtimestarin
kauniissa, hauskassa huoneessa, tuli sisään tallustaen ja veti nyt
Sanna-Kaisan mukanaan. Hän tahtoi näyttää hänelle uuden
nukkensa, sellaisen oikean, jolla oli kirkkaat silmät hienossa
posliinipäässä, ja hän tahtoi, että he laulaisivat ja tuutisivat hänet
uneen, kuten heidän oli ollut tapana tehdä entisille nukeilleen.
Pienokaiset valmistivat nukelle vuoteen sänkykamariin. Siellä
kasvattivanhempien luona oli Martta-Eevalla nyttemmin oma, hieno
sijansa pienessä sirossa sängyssä. Sanna-Kaisa laski myöskin oman
nukkensa, riepuihin kiedotun halon, konelaatikkoon —. Sitte
pikkutytöt lauloivat suloisesti ja hartaasti laulunsa taivaallisesta
Kaanaasta molemmille unisille nukeille keikuttaen laatikkoa
välillänsä.
Kerttu, kasvattiäiti, juoksi hakemaan miestään. Hänen täytyi kuulla
ja nähdä heidät yhdessä, nähdä ja verrata jo punaposkista, vapaasti
katselevaa pientä löytölasta sievissä, oivallisissa vaatteissaan,
toiseen, pieneen, kalpeaan raukkaan kärsivine katseineen ja
ohkaisine, lopen kuluneine repaleilleen. Kerttu tiesi hyvin,
minkätähden hän halusi esittää tämän kuvan miehelleen.
Molemmat puolisot seisoivat toisiinsa nojautuneina, kuunnellen
lasten laulua.
Artur sinä. — He laulavat 'Taivaan Kaanaasta'. Kuule tätä pientä,
uutta tulokasta! Eikä 'Kankaiden hanhista', lisäsi hän arasti. Ei kai
tuo pieni Jumalan enkeli ole mielestäsi sinua narrannut?
Ei, totisesti, ei. Sanon sinulle, etten nyt ensinkään tahtoisi olla
ilman häntä. Talossa tulisi taas niin tyhjää ja hiljaista.
Muistatko sananlaskua: 'Pata, joka keittää yhdelle, keittää yhtä
hyvin kahdelle'.
Sanotko niin —!
Jahtimestari katseli miettivän näköisenä lattialla istuvia pienoisia,
jotka yhä lauloivat ja keikuttivat konelaatikkoa välillään. Toinenhan
heistä hänen täytyi pitää ja hän tahtoikin sen tehdä. Mutta toisen —
tuon kalpean pienen olennon, ohuine poskilleen ja tummine,
kärsivine silmineen — niin, hänen täytyi taas maantielle. Eikä kellään
heistä ollut äitiä eikä isää, sen oli hänen vaimonsa kertonut.
No niin, anna sitte Jumalan nimessä padan kiehua kahdelle,
sanoi hän viimein.
Lapset lauloivat laulamistaan kasvattivanhempien totisina, kirkkain
kasvoin mennessä suurempien lasten luo, jotka istuivat keittiössä
puhellen Tuovin kanssa. He eivät tahtoneet ottaa pienoisia ilman
suurempien myöntymystä. Ja voihan käsittää, että pikkutyttöjen oli
hyvä jäädä pieneen taloon, missä itse ikkunatkin hymyilivät ja
vilkkuivat katon harjan alla, ja missä seinätkin olivat kuin puoloilla ja
kermalla siveltyjä.
Kahdestoista luku.
TYÖ-ANSIOITA JA RAHAKYSYMYKSIÄ.
Kun jäljelläolevat lapset nyt jatkoivat matkaansa, eivät heidän
ajatuksensa enää olleet niin raskaita. Heillä oli niin paljon ihmeellistä
puhuttavana. Ensiksikin koreasta rouvasta, jonka silmät olivat niin
lempeät. Lakanoista pitseineen ja punaisista peitteistä pikkutyttöjen
vuoteissa ja hienosta, hyvästä ruuasta, jota pienokaisilla nyt alati
olisi.
Ja nähkääs, he ovat tulleet oikeitten ihmisten luo, sellaisten,
joihin äitikin olisi suostunut, sanoi Antti totisesti. Rouva istui eilen
illalla korisängyn ääressä ja antoi pikkutyttöjen lukea pienen
rukouksensa, ja sitte hän sanoi, että he rukoilisivat Jumalaa
suojelemaan sisaruksia, jotka kulkevat ulkona maailmalla, ja
antamaan meidän kaikkien tulla kilteiksi, hyviksi ihmisiksi. Siitä minä
pidin, siksi he saivat jäädä sinne.
Olisi kai sinun pitänyt antaa heidän jäädä suurtaloonkin, jos he
olisivat tahtoneet pitää pikkutytöt, vaikka väki olikin sekä nyrpeää
että häijyä, sanoi Anna-Liisa vähän pisteliäästi.
Ei koskaan, puuttui Antti kiivaasti puheeseen, tiedä se. —
Sinnekö, missä isäntä niin ankarasti kirosi! Mikä onnettomuus
hyvänsä voi kohdata sellaista taloa; ja siitä saisivat pikkutytötkin
kärsiä.
Niin, lisäsi Mauno, ja pihalla huusivat rengit, joiden piti asettaa
hevoset takarekien eteen, alituisesti 'tuhat perkelettä'.
Hui, sehän on aivan hirvittävää, sanoi Matleena kauhistuen.
Näin hän sanoi, jatkoi Mauno ikäänkuin hyvillänsä saadessaan
sitä hirvittävää toistaa: Anna tänne se perkeleen kirves, että saan
lyödä naulapahuksen kirottuun takarekeen.
Vaiti poika! Oletko hullu, kun suorastaan vedät onnettomuutta
ylitsemme puhumalla niin kauheita sanoja. Äiti, kun aina niin pelkäsi
kirosanoja, sanoi Antti pelästyneenä ja pahoillaan. Eikä teidän toki
tarvitse ajatella, että olisin jättänyt pikkutytöt sellaiseen taloon,
vaikka he olisivatkin saaneet nisujauhopannukakkua ja sianlihaa ja
vehnäskahvia joka ikinen päivä.
Niin, pikkutytöt olisivat kai oppineet kiroamaan sellaisessa talossa
hekin, epäili Pekka-Erkki.
Mutta niillä oli siellä neljä hevosta, ja seinällä pyssy, ja isännällä
oli tuppipuukko, joka oli oikein kaunis, niin että kyllä pikkutytöt
olisivat tavallansa voineet sielläkin hyvin, arveli Mauno.
Nyt saatte nähdä tuppipuukon, jonka sain jahtimestarilta,
keskeytti Antti. Hän otti povestaan tuppeen pistetyn puukon, jossa
oli musta kiiltävä varsi ja nahkatuppi, ja jonka terä oli ohutkärkinen
ja välkkyvän terävä.
Ei mutta, poika!
Mauno pysähtyi keskelle tietä kuin kivettyneenä. Sillä kai on tuhat
kruunua, joka hennoo antaa pois tuollaisen. Mistä se tuli, että hän
sen teki?
Minun piti auttaa Tuovia päreitä pilkkomaan, ja minulla oli vain
vanha puukkoni. En tiedä, liekö hän sanonut jotakin jahtimestarille,
mutta kun olin hänen luonaan sisällä kiittämässä meidän
edestämme, antoi hän minulle puukon. Ja sitte hän sanoi, että
kunnon poika, joka osaa hyvin käyttää puukkoansa, aina voi tulla
toimeen maailmassa ja kunnialla päästä eteenpäin.
Sellainen puhe kuuluu korealta, sanoi Matleena uneksien. Se
rouva, joka oli niin kovasti näppärä, antoi minulle niin hienoa lankaa.
Tässä saatte nähdä. —
Matleena otti esiin paperitötterön ympärilleen solmitusta saalista.
He pysähyttivät kelkan. He olivat nyt keskellä metsikköä poissa
ihmisten silmistä. Matleena istui kelkkaan.
Kas tässä — punaista lankaa ruusuihin, ja vihreää lehtiin, ja
ruskeaa varsiin.
Mutta mihin — mihin hyvänen aika ne ovat aiotut? kysyi Anna-
Liisa yhtä hämmästyneen näköisenä kuin toisetkin sisarukset, jotka
äärimmäisen kummastuksen valtaamina ottivat Matleenan koreuden
katseltavakseen. Joukossa oli myöskin harmaa lankakerä, johon oli
kiinnitetty luinen virkkineula, sukkavarraskerta ja kiiltävä parsinneula.
Tuo taitava rouva sanoi minulle näin: 'Osaatko kutoa?' sanoi hän.
Hertti, tottahan sitä osannet, suhahti Anna-Liisa.
Älä nyt — niinhän minä sanoinkin. — Voithan antaa minun puhua
loppuun! 'Kyllä', sanoin minä.
No, mitä hän sitten sanoi? kysyi Mauno innokkaasti.
'Tässä saat nähdä', sanoi hän.
Mitä sitte sait nähdä? intoili Pekka-Erkki, joka kuljetti kättänsä
korean langan yli kuin olisi tahtonut hyväillä sitä.
Surkeus suuri, kuinka te kyselette ja pidätte meteliä, niin että
minä syön, mitä minun piti sanoa, enkä enää muista sitä!
Sinun piti saada nähdä jotakin, auttoi Antti häntä tolalle.
Niin se oli, mutta vaiti nyt. Hän näytti minulle parin lapasia,
nähkääs, niin hienoja lapasia, ettette ole sellaisia nähneet.
Ne kai maksavat paljon rahaa, se on tietty, sanoi Mauno
ajattelevaisesti.
Niin kyllä, näetkös, mutta ei sille, joka voi valmistaa sellaisia —
sillä silloin maksaa ainoastaan lanka.
Lanka, niin, mutta ei se maksane vähän sekään, tuumasi Anna-
Liisa.
Te sitte vasta olette kiusallisia keksimään ikävyyksiä, niin että
minä töin tuskin haluan puhua loppuun, napisi Matleena. Hän otti
kuitenkin armollisesti esille puoleksi kudotun lapasen, missä
valkoinen villalanka vielä oli kiinni.
Se oli valmistettu koukkuamalla, millä tavalla Norrlannin naiset
ennen pienellä luukoukulla virkkasivat erinomaisen lujia lapasia. Ja
lapasen puoliskolle oli villalangalla neulottu punaisia ruusuja, vihreitä
lehtiä ja ruskeita varsia.
Annas olla, joko nyt käsitätte, missä ruusujen ja lehtien paikka
on?
Matleena salli pienen lapaspuolikkaan kulkea sisarusten kesken.
Niin, mutta kuka sen nyt tekee! Et sinä nyt ainakaan voi saada
aikaan sellaista, joka on niin hienoa ja mutkikasta, sanoi Mauno
ylimielisesti ja musertavalla varmuudella.
Ei, se on selvää, kinasteli Matleena. Sinä kai luulet itse siihen
paremmin pystyväsi — sinä, joka parsii sukkia niinkuin kurotaan
kiinni jauhopussin suu, vedät vain reijän kokoon — vaikka se olisi
kuinka suuri.
Matleena, varo itseäsi, ettet tule suulaaksi, muistutti Antti. Eikä
ollenkaan ole somaa, kun naisväki käy sellaiseksi.
Sittepähän mies voi olla vaiti, kun ei tiedä mitään siitä, josta pitää
ääntä.
No, senhäntähden kysyy, kun ei mitään tiedä, jatkoi Antti
sävyisästi. En minäkään tiedä, miten sinä menettelet noiden
ruusujen suhteen, tai miten saat aikaa sellaiseen työhön.
Niin, mutta minä tiedän. Kun sinä eilen olit ulkona ja kannoit
heille vettä ja loit lunta, olin minä sisällä rouvan luona, ja hän auttoi
minua laittamaan tämän nutun. Ja minä sain neuloa tämän
esiliinankin itselleni.
Minäkin sain ommella itselleni sellaisen, sanoi Anna-Liisa
ylpeästi.
Ja kun se oli tehty, näytti hän minulle, miten minun pitäisi
koukuta.
— Katsokaas näin! Mutta se on tietysti peräti mutkallista.
Pakkasen punertamin, jäykin sormin, nenä vuotavana ja suu
juhlallisesti kokoonpuristettuna näytti Matleena sisarusten silmissä
ihmeteltävää koukkuamistaitoaan.
Ja sitte, nähkääs, tulee kaikista merkillisin.
Hän pujotti tärkeän näköisenä punaisen langan parsinneulan
silmään. Sitte katsokaas — tulee kaikista kummallisin. — Että minä
osaan neuloa — näin — koreaa.
Hän neuloi vain muutamia pisteitä, mutta sekin jo herätti
sisaruksissa tarpeellista kunnioitusta.
Matleena hypähti pystyyn, pisti langan talteen ja otti oikean
ajoluiun, sillä eipä luminen maa monen asteen pakkasessa ollut juuri
sopivin neulomakoulun paikka.
Tästä lähtien, nähkääs, koukkuan lapasia ja neulon niihin ruusuja
ja — myyn niitä, kuulettekos, — ja saan rahaa ja ostan meille pienen
tuvan, joka näyttää puolukoilta ja kermalta, ja jossa on nauravat
ikkunat. Pikkutytöt ja kaikki tyyni teemme sitte lapasia. Oikeita oman
maan lapasia —, sillä rouva sanoi, että tekisimme kaikki aivan kuin
ajatellen oman maan nimen tulevan työhön mukaan; kaikki tehtävät
ovat suoritettavat tietysti sillä tavalla, ettei isänmaa joudu häpeään.
Kun vain tulee kevät, rupean kulkiessani kutomaan, sillä hän sanoi,
että näin on vaimoväki täällä ennenkin tehnyt. Kudon pikkusukkia
teille päivin ja sitte illoin, kun istumme jossakin koivuhaassa,
koukkuan ja neulon ruusuja, joista tulee niin koreita kuin
orjanruusut.
Minä en suinkaan aio ryhtyä lapasia koukkuamaan, sanoi Mauno
ojentautuen ja kääntäen ranteista liian pitkiä, riippuvia
nutunhihojaan. Ei, minä puolestani lähden Amerikkaan ja kaivan
niin paljon kultaa, että voin ostaa koko Hallatunturin pitäjän ja
kirkon, jos tahdon, ja täyttää sen karpaloilla ja tuoreilla juustoilla ja
luhdikoilla ja sianlihalla ja — Mauno kellahti sivuun.
Kohti kurkkua huutaen ja pelästyneenä hän koetteli kädellä
poskeaan. Siinä poltti korvapuusti. Antti, joka ei ollut kurittanut
lapsia äidin eläessä, ja joka tavallisesti oli ihmeellisen kärsivällinen
heidän suhteensa, vihastui tulisesti. Mauno sai korvapuustin, ja Antti
rupesi häntä puristelemaan, juuri kuin hän olisi ollut perunasäkki,
johon oli saatava enemmän tilaa.
Poika, ettet häpeä! — Pidätkö vierasta maata parempana omaa
—! Lähteä sinne kullan hakuun! — niinkuin meidän setä, joka on
turmellut siellä itsensä. Ja vielä sekin, että kullalla ostaisit kirkon siksi
vain, että pitäisit koreaa kirkkoa, missä Jumalasta saarnataan,
aittana —. Sinulla on, Mauno, ilkeä mieli, ja tuollaista puhetta en
kärsi kuunnella.
Lapset kävelivät tavallista kulkijahölkkää, sangen noloina Antin
odottamattomasta kiukunpuuskauksesta. Mauno pirottaen ja itkua
tuhertaen.
Miehen on paljon parempi tehdä lapasia kunnialla kuin nostaa
säkittäin kultaa ja käyttää sitä siihen, mikä on pahaa — muista se,
Mauno, jatkoi Antti vielä aivan hengästyneenä harmista. Hän kahlasi
metsikköön kinoksen läpi ja leikkasi terävällä puukolla kuusenlatvan,
jonka oksat olivat niin tasaisena kehänä rungossa kiinni, että se
hyvin sopi männäksi. Hän koetti jälleen leppyä.
Kun eivät pikkutytöt nyt istu kelkassa, sanoi hän, niin olen
ajatellut kuljettaa siinä työaineksia askartaakseni iltaisin, kun
tulemme johonkin taloon, missä on tuli takassa, tai jonnekin
leipomatupaan tai renkikamariin.
Aiotko tehdä mäntiä ja pesimiä myytäväksi? kysyi Anna-Liisa
jonkinlaisella kunnioituksella mahtavalta veljeltään.
Niitä olen enimmäkseen ajatellut. Puulusikoita myöskin. Simo-
Paavalin vaari oli mainio lusikoita tekemään, mutta eihän minulla
koskaan ole ollut puukkoa, että olisin voinut veistää niiden mukaan.
Ne minä sinulle maalaan, huusi Matleena metsikköön päin
Antille. Niin koreita, pieniä, sinisiä ruusuja ja vuohensilmiä.
Valmistan väriä, niinkuin äitikin, lehdistä, kukkasista ja juurista.
Saanko auttaa sinua lusikoita tekemään, kun tulen suureksi?
mutisi
Mauno, tullessaan Antin läheisyyteen tiellä.
Saat kyllä, poika. Kas tässä vanha puukkoni, sillä voit, vaikka olet
pieni, alkaa tehdä aineksia.
Voimmehan myydä lusikat, Antti, ja saada rahaa. Mutta en minä
sentään ostakaan kirkkoa, sillä pappi ei voi siellä silloin lukea.
Ei, emmekä me voi istua siellä ja kuunnella häntä ja veisata ja
lukea, että meistä tulisi hyviä ihmisiä, niinkuin äiti toivoi.
Kolmastoista luku.
VAINAJAN SIJAAN.
Kun lapset muutamia päiviä myöhemmin ehtivät niin kauvas, että
pääsivät pahimmasta tunturiseudusta, tulivat he eräänä iltana
taloon, missä sairaus ja surut olivat vieraina. Suureen, rikkaaseen
talonpoikaistaloon. Vanhin tyttö oli siellä äsken kuollut ainoastaan 10
vuoden vanhana. Ja nyt makasi pieni poju, ainoa poika,
seitsenvuotias, sairaana samassa taudissa, johon sisar oli kuollut.
Vaimo, uljas, kaunis nainen, seisoi takan ääressä ja vispilöitsi
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

More Related Content

PDF
Windows Powershell in Action 1st Edition Bruce G. Payette
PDF
The Real MCTS SQL Server 2008 Exam 70 433 Prep Kit Database Design 1st Editio...
PDF
Linux Unveiled: From Novice to Guru Kameron Hussain
PDF
Microsoft Hyper V Cluster Design 1st Edition Eric Siron
PDF
Getting Started With Purequery V Rodrigues Et Al
PDF
Beginning Python 1st Edition Norton Peter C Samuel Alex Aitel
PDF
Python Data Persistence With SQL and NOSQL Databases 1st Edition Lathkar
PDF
Survey of Operating Systems 5th Edition Holcombe Solutions Manual
Windows Powershell in Action 1st Edition Bruce G. Payette
The Real MCTS SQL Server 2008 Exam 70 433 Prep Kit Database Design 1st Editio...
Linux Unveiled: From Novice to Guru Kameron Hussain
Microsoft Hyper V Cluster Design 1st Edition Eric Siron
Getting Started With Purequery V Rodrigues Et Al
Beginning Python 1st Edition Norton Peter C Samuel Alex Aitel
Python Data Persistence With SQL and NOSQL Databases 1st Edition Lathkar
Survey of Operating Systems 5th Edition Holcombe Solutions Manual
Ad

Professional Sql Server 2008 Administration With Windows Powershell 1st Edition Ananthakumar Muthusamy

  • 1. Professional Sql Server 2008 Administration With Windows Powershell 1st Edition Ananthakumar Muthusamy download https://ebookbell.com/product/professional-sql- server-2008-administration-with-windows-powershell-1st-edition- ananthakumar-muthusamy-55089264 Explore and download more ebooks at ebookbell.com
  • 2. Here are some recommended products that we believe you will be interested in. You can click the link to download. Professional Microsoft Sql Server 2008 Administration Wrox Programmer To Programmer 1st Edition Brian Knight https://ebookbell.com/product/professional-microsoft-sql- server-2008-administration-wrox-programmer-to-programmer-1st-edition- brian-knight-2195688 Professional Sql Server 2005 Administration Brian Knight Ketan Patel https://ebookbell.com/product/professional-sql- server-2005-administration-brian-knight-ketan-patel-978350 Professional Sql Server 2008 Internals And Troubleshooting Christian Bolton Et Al https://ebookbell.com/product/professional-sql-server-2008-internals- and-troubleshooting-christian-bolton-et-al-4106416 Professional Microsoft Sql Server 2008 Reporting Services Wrox Programmer To Programmer 1st Edition Paul Turley https://ebookbell.com/product/professional-microsoft-sql- server-2008-reporting-services-wrox-programmer-to-programmer-1st- edition-paul-turley-2505620
  • 3. Professional Microsoft Sql Server 2008 Integration Services Wrox Programmer To Programmer Brian Knight https://ebookbell.com/product/professional-microsoft-sql- server-2008-integration-services-wrox-programmer-to-programmer-brian- knight-2505622 Professional Microsoft Sql Server 2008 Programming Robert Vieira https://ebookbell.com/product/professional-microsoft-sql- server-2008-programming-robert-vieira-5473568 Professional Microsoft Sql Server Analysis Services 2008 With Mdx Sivakumar Harinath https://ebookbell.com/product/professional-microsoft-sql-server- analysis-services-2008-with-mdx-sivakumar-harinath-4106380 Beginning Sql Server 2008 For Developers From Novice To Professional 1st Edition Robin Dewson https://ebookbell.com/product/beginning-sql-server-2008-for- developers-from-novice-to-professional-1st-edition-robin- dewson-1265480 Professional Microsoft Sharepoint 2007 Reporting With Sql Server 2008 Reporting Services 1st Edition Coskun Cavusoglu Jacob J Sanford Reza Alirezaei https://ebookbell.com/product/professional-microsoft- sharepoint-2007-reporting-with-sql-server-2008-reporting-services-1st- edition-coskun-cavusoglu-jacob-j-sanford-reza-alirezaei-51603320
  • 5. Professional SQL Server® 2008 Administration with Windows PowerShell™ Muthusamy Anantha Kumar Yan Pan Wiley Publishing, Inc.
  • 6. Professional SQL Server® 2008 Administration with Windows PowerShell™ Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2009 by Wiley Publishing, Inc., Indianapolis, Indiana Published by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-47728-1 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 Library of Congress Cataloging-in-Publication Data Kumar, Muthusamy Anantha, 1974- Microsoft SQL server 2008 administration with Windows Powershell / Muthusamy Anantha Kumar, Yan Pan. p. cm. Includes index. ISBN 978-0-470-47728-1 (paper/website) 1. SQL server. 2. Windows PowerShell (Computer program language) I. Pan, Yan, 1976- II. Title. QA76.73.W56K96 2009 005.2’82--dc22 2009013304 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Wrox Programmer to Programmer, and related trade dress are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. SQL Server and Windows PowerShell are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books.
  • 7. Contents Introduction xxi Chapter 1: What Is Windows PowerShell? 1 Command-Line Interfaces versus Graphical User Interfaces 1 Prerequisites for Installing Windows PowerShell 2.0 2 Installing the Microsoft .NET Framework 6 Installing Windows Remote Management 6 Installing Windows PowerShell 7 Launching Windows PowerShell 10 Using the Command console 11 Using All Programs 11 Using Start Run 11 Summary 13 Chapter 2: Windows PowerShell Command Types, Snap-ins, and cmdlets 15 PowerShell Command Types 16 Native Commands 16 PowerShell cmdlets 18 Shell Function Commands 19 Script Commands 20 Calling PowerShell cmdlets or Scripts from the Command Shell 22 PowerShell Snap-ins 23 Core 24 Host 25 PowerShell.Management 25 Security 26 Utility 27 Diagnostics 27 WsMan.Management 28 PowerShell cmdlet Syntax 28 Named Parameter 28 Positional Parameter 29 Command Chaining 30
  • 8. Contents Getting Help 31 Filtering 34 Sorting 38 Formatting 39 Summary 42 Chapter 3: Windows PowerShell Programming, Scripting, Error Handling, and Debugging 43 PowerShell Scripts 44 PowerShell Variables 44 Arrays 48 Expressions 49 Operators 50 Conditional Expressions 52 IF Statement 53 Loop Construct 54 For Loop 55 While Loop 55 Do-While Loop 56 Do-Until Loop 56 Foreach Statement 57 Input 58 PowerShell Scripting 59 Text File As Input 62 Output 64 Writing to the Console 64 Writing to a File 65 Error Handling 67 Debugging 71 Summary 75 Chapter 4: Windows PowerShell Functions, Parameters, Sourcing, Scopes, and User Profile 77 Functions 77 Arguments in Functions 78 Returning Values 80 Script Parameters 81 Sourcing 84 Variable Scope 85 xiv
  • 9. Contents Function Scope 87 User Profile 88 Transcripts 90 Summary 91 Chapter 5: Working with the File System, Registry, and Variables 93 Using Get-PSDrive and Get-PSProvider 93 Working with File System 95 Navigating the File System 96 Managing Files and Directories 98 Managing File Contents 106 Working with the Registry 108 Working with Variables 111 Automatic Variables 113 Preference Variables 115 User-Created Variables 116 Working with Environment Variables 121 Summary 122 Chapter 6: Working with Event Logs 123 Event Log Service 124 Event Viewer 125 Event Logs 125 Log Entry Types 128 Exporting the event logs 134 PowerShell cmdlets Related to event log 136 Summary 140 Chapter 7: Working with Windows Services and Processes 141 What Is a Windows Service? 141 Windows PowerShell and Windows Services 143 Get-Service 144 Stop-Service 146 Start-Service 148 Set-Service 150 Working with Windows Processes 151 Get-Process 153 Stop-Process 155 Summary 157 xv
  • 10. Contents Chapter 8: Working with WMI 159 Permission Issues and WMI 159 The WMI Model 161 Working with Event Log 164 Working with Services 170 Working with Processes 179 Working with Environment Variables 186 Working with the Registry 190 Summary 195 Chapter 9: WMI Provider for Configuratio Management 197 Managing SQL Server Services 198 Managing Client Network Protocols 203 Managing SQL Server Client Aliases 207 Managing Server Network Protocols 211 Changing FILESTREAM Settings 214 Changing SQL Server Advanced Properties 216 Summary 218 Chapter 10: WMI Provider for Server Events 219 WMI Provider for Server Events 219 WMI Query Language (WQL) 220 Event Handling with Windows PowerShell 2.0 221 Monitoring Errors from the SQL Server Error Log 225 Monitoring Deadlocks 226 Monitoring Blockings 229 Monitoring Login Changes and Failed Login Attempts 233 Monitoring Databases 235 Monitoring Database Objects 236 Summary 239 Chapter 11: Windows PowerShell in SQL Server 2008 Environment, SQL Server PowerShell Provider 241 sqlps Utility 241 SQLSERVER: Drive and Invoke-Sqlcmd cmdlet 245 SQL Snap-ins 245 Encoding and Decoding Uniform Resource Name (URN) 256 Summary 258 xvi
  • 11. Contents Chapter 12: Managing Policies through SQLSERVER: SQLPolicy 259 SQLSERVER: SQLPolicy Folder 259 Conditions 263 Policies 268 Summary 281 Chapter 13: Windows PowerShell and SMO 283 PowerShell and the SQLConnection .NET Class 283 Working with SQL Server using SMO 290 Methods and Properties 291 Getting Version Information 291 SQL Server SPID Information 292 SQL Server Server-Related Information 293 SQL Server Database-Related Information 295 Changing the Login Mode 296 Host Information 296 Performance Counters 297 Working with Databases using SMO 297 Working with Tables using SMO 304 Creating Tables 305 Listing Columns 305 Removing Columns 306 Adding Columns 307 Dropping a Table 308 Backup and Restore with SMO 308 Database Backup 308 Transaction Log Backup 311 Differential Backup 312 Restoring Full Backup 313 Restoring a Full Backup and Transaction Log Backup 313 Summary 316 Chapter 14: Building SQL Server Standards and PowerShell Coding Standards 317 SQL Server Standards 318 SQL Server Development Standards 318 Naming Conventions 318 General Rules 320 Stored Procedure Standards 321 Keep Them Small 321 ‘‘DBO’’ As Object Owner 321 xvii
  • 12. Contents Use Comments Generously 321 Select * 322 Cursors 322 Temporary Tables 322 Things to Avoid 322 Things to Use 323 Check @@ERROR 323 Use SQL Server Date Data Types 323 DML Statements 323 ANSI-Standard Join Clauses 323 Deprecated Features 324 Database Design Standard and Best Practices 324 User-Define Tables 324 Logs 324 Split tempdb 325 Databases 325 Security and Roles 325 Auto Create and Auto Update 325 Size 325 Auto Shrink and Auto Close 325 Design and Performance 326 Store Unstructured Data 326 More Performance Guidelines 326 Data Protection Standards and Best Practices 327 Backup Policy 327 SQL Server Production Standards 327 High Availability and Disaster Recovery 327 The Administration Database 328 The Scratch Database 328 Centralized Inventory Server 328 Database File Location and RAID 328 Segregation 328 Features 328 PowerShell Coding Standard 329 Default Parameters 329 Log File 329 Log Format 329 Comments 330 Display 330 Variable Naming Convention 330 Exception Handling 330 Summary 331 xviii
  • 13. Contents Chapter 15: Building SQL Server Inventory 333 SQL Server Inventory 333 Hosts 335 Clusters 346 ClusterNodes 350 Servers 355 Databases 368 Supplementary Tables 373 Summary 376 Chapter 16: SQL Server Installation 377 Installation Procedure and Template 377 SQL Server Installation Template 381 Standalone Installation Example 389 Cluster Installation Example 395 Summary 399 Chapter 17: Collecting SQL Server Performance and Host Performance Data 401 SQL Server Performance Data Collection 401 SQL Server Host Performance Data Collection 408 Summary 417 Chapter 18: Monitoring SQL Server 419 Pinging SQL Server Hosts 420 Checking SQL Server–related Services on SQL Server Hosts 423 Checking Uptime of SQL Server Hosts 427 Monitoring Windows Event Logs 429 Monitoring SQL Server Error Log 433 Monitoring Blockings 439 Monitoring Deadlocks 444 Summary 449 Chapter 19: Monitoring Disk Space Usage, Database Files, and Backups 451 Monitoring Disk Space Usage 451 Monitoring Database Files 461 Monitoring Backups 468 Summary 473 xix
  • 14. Contents Chapter 20: Definin Policies 475 Stored Procedure Naming Convention Policy 475 Auto_Close and Auto_Shrink Off Policy 480 Summary 485 Chapter 21: Generating Database Scripts 487 Scripting Databases 487 Scripting Schemas 489 Scripting User-Define Data Types 491 Scripting Tables 494 Scripting User Views 496 Scripting Stored Procedures 498 Scripting Functions 500 Scripting XML Schemas 502 Scripting Users 503 Summary 506 Appendix A: cmdlets 507 cmdlets Related to Core Snap-ins 507 cmdlets Related to the PowerShell Management Snap-in 512 cmdlets Related to the Security Snap-in 519 cmdlets Related to the Utility Snap-in 520 Index 531 xx
  • 15. Introduction Welcome to SQL Server 2008 Administration with Windows PowerShell. This book is a nuts-and-bolts guide to creating Windows PowerShell scripts that can be used to administer every aspect of the SQL Server 2008 Database Engine. Using a very hands-on approach, this book guides you through the basics of Windows PowerShell, the available Windows PowerShell components that have been integrated into SQL Server 2008, and the actual administration tasks. By providing clear, well-structured examples, SQL Server 2008 Administration with Windows PowerShell shows you how to construct effective and practical solutions that can improve SQL Server administration and monitoring at your company. SQL Server 2008 delivers a dynamic, smart, and productive data platform for all your data-related needs. SQL Server 2008 offers secure, reliable, and consistent performance. It is also very scalable and flexible, handling any form of data. It is well known in the technology world that SQL Server 2008 is not only a RDBMS, but also has built-in features such as Integration Services for ETL, Analysis Services for Business Intelligence, Reporting Services for report management, and more. This is why Microsoft SQL Server is a cut above all other database products. Windows PowerShell 2.0 is the new extensible command-line interface shell and scripting language that provides an environment for interactive scripting and non-interactive scripted administration of local and remote computers. Because Windows PowerShell integrates with the Microsoft .NET Framework, we can take advantage of all the features of .NET as well. Windows PowerShell 2.0 helps system admin- istrators to automate and manage various aspects of the Windows environment. PowerShell 2.0 also has many new and useful features such as remoting, eventing, and many more. For these reasons, Windows PowerShell 2.0 stands above all the system administration products on the market. This book brings together the best of both worlds — namely, the database world and the administra- tion world — to help you manage, automate, and control your environment. This book combines three technologies — SQL Server 2008, the .NET Framework, and Windows PowerShell 2.0 — and guides SQL Server database administrators in managing a server plant using Windows PowerShell 2.0. We’ve provided a wide range of material in a tutorial-based book to get you over the learning curve of Windows PowerShell 2.0 and SQL Server 2008 database administration. Who This Book Is For Whether you are a SQL Server database administrator, a developer, or a systems administrator, at some point you probably have had to develop or administer the system or the database in your organization. It is also common for the people in these roles to wear each other’s hats in order to get things done. If you are a Microsoft SQL Server database administrator, you know that you cannot manage and access all the system resources from SQL Server. Because SQL Server runs on top of the Windows operating system and relies on the health of the system, you need information from the system side as well. This book will teach you to manage both SQL Server and system resources using Windows PowerShell 2.0.
  • 16. Introduction If you are a systems administrator and would like to know more about SQL Server database adminis- tration, this book introduces you to the features in SQL Server 2008 and provides plenty of examples demonstrating how to manage SQL Server 2008 using Windows PowerShell 2.0. This book is also appropriate for those who have some exposure to systems administration and SQL Server administration, or for those who want to expand their skill set to include administration. What This Book Covers This book covers the fundamentals of Windows PowerShell 2.0 cmdlets. It includes programming, script- ing, debugging, and error handling in PowerShell. It covers all Windows administration related to SQL Server 2008 using Windows PowerShell 2.0. It also introduces Windows Management Instrumentation (WMI) and explains how to write WMI scripts in Windows PowerShell to perform system and SQL Server 2008 administrative tasks. This book also covers the WMI providers for SQL Server. These useful providers enable you to manage SQL Server services and network connectivity, and proactively monitor SQL Server events. You will also discover the new Eventing feature in Windows PowerShell 2.0. Additionally, the new SQL Server 2008 support for Windows PowerShell is presented. It illustrates the SQL Server PowerShell provider and SQLSERVER: drive. You will also learn how to manage SQL Server objects, including the new policy objects. One more important topic this book covers is using SQL Server Management Objects (SMO) to create databases and tables and perform backups and restores. The SMO scripts shown in this book are all written in Windows PowerShell 2.0. This book also explains the need for SQL Server standards; and you will learn how to build a SQL Server inventory over an existing or new environment. Finally, you will learn how to perform the various SQL Server administrative tasks on servers in the inventory, such as installation, monitoring, performance data collection, policy definition, backups, restores, database scripting, and more, using Windows PowerShell 2.0. How This Book Is Structured Windows PowerShell 2.0 is introduced in the first eight chapters. If you do not have any background in Windows PowerShell 2.0, these chapters are critical. They help you understand the basics of writing Windows PowerShell 2.0 scripts, and you will learn how to use the scripts to administer the overall operating system. Chapter 1 covers installation of prerequisites, and installation and configuration of Windows PowerShell 2.0. Chapters 2, 3, and 4 cover the various cmdlets available in Windows PowerShell, and the various pro- gramming features such as inputs, outputs, debugging, error handling, functions, profiles, and so on. xxii
  • 17. Introduction Chapters 5, 6, 7, and 8 cover the various systems administration features, including accessing file systems, registry information, variables, and Event logs. It also explains the Windows Management Instrumenta- tion (WMI) model and shows you how to use WMI to manage system resources. Chapters 9 and 10 show you how to access the WMI providers for SQL Server. You will learn how to use the WMI Provider for Configuration Management to manage SQL Server services and network connec- tivity, and the WMI Provider for Server Events to manage SQL Server events. You will also discover the new Eventing feature in Windows PowerShell 2.0. Chapters 11 and 12 take on the Windows PowerShell support that has been integrated into SQL Server 2008, namely, the SQLSERVER: drive. These two chapters will focus on the SQL and SQLPolicy folders separately. Chapter 13 shows you how to write SQL Server Management Objects (SMO) programs in Windows PowerShell 2.0. This chapter covers various tasks such as creating a database and database objects, and backing up and restoring a database. Chapters 14 and 15 provide you with ample examples of building a SQL Server tasks inventory over an existing or new environment, and how to define various standards. Standards include both SQL Server standards and Windows PowerShell standards. The remaining chapters explain installation, data collection, monitoring, and how to create Windows PowerShell scripts to handle a wide range of SQL Server administrative tasks for servers in the inventory. Chapter 16 illustrates the installation of SQL Server 2008. Chapter 17 covers tasks related to collecting SQL Server host and server performance data. Chapters 18 and 19 cover monitoring aspects of SQL Server 2008 administration. Chapter 20 defines policies to enforce SQL Server standards, and Chapter 21 generates various scripts at both the database level and the database object level. What You Need to Use This Book This book covers SQL Server 2008 administration with Windows PowerShell 2.0. In order to use this book, you need both a server-side component and client-side components: ❑ For the server-side component, you need SQL Server 2008 Developer or Enterprise or Standard edition. ❑ For client-side components, you need Windows PowerShell 2.0 CTP3. To install Windows PowerShell 2.0 CTP3, the operating system of your computer needs to be either Windows XP Service Pack 3, Windows 2003 Service Pack 2, Windows Vista Service Pack 1, or Windows Server 2008. You also need to pre-install the following components on your computer: ❑ Microsoft .NET Framework 2.0 or greater ❑ Windows Remote Management 2.0 CTP3 for Windows PowerShell remoting and back- ground jobs We discuss the prerequisites of Windows PowerShell 2.0 in Chapter 1 in detail. xxiii
  • 18. Introduction All the scripts and codes in the book have been tested on SQL Server 2008 with .NET Framework 3.5 and Windows PowerShell 2.0 CTP3. We tested all the scripts on Windows XP, Windows Server 2008, and Windows Vista. Most of the scripts and code illustrated here work under Windows PowerShell 1.0 as well, although you may notice that the output of such scripts and codes differs slightly, and that remoting under Windows PowerShell 1.0 is not possible unless you use WMI objects. In order to install Windows PowerShell 2.0 and Windows Remote Management, and to store all the scripts provided in the book, you need a minimum of 100MB of hard disk space. Conventions To help you get the most from the text and keep track of what’s happening, we’ve used a number of conventions throughout the book. Notes, tips, hints, tricks, and asides to the current discussion are offset and placed in italics like this. As for styles in the text: ❑ We highlight new terms and important words when we introduce them. ❑ We show filenames, URLs, and code within the text like so: persistence.properties. ❑ We present code like this: We use a monofont type with no highlighting for most code examples. Source Code As you work through the examples in this book, you may choose either to type in all the code manually or to use the source code files that accompany the book. All of the source code used in this book is available for download at www.wrox.com. Once at the site, simply locate the book’s title (either by using the Search box or by using one of the title lists) and click the Download Code link on the book’s detail page to obtain all the source code for the book. Because many books have similar titles, you may find it easiest to search by ISBN; this book’s ISBN is 978-0-470-47728-1. Once you download the code, just decompress it with your favorite compression tool. Alternately, you can go to the main Wrox code download page at www.wrox.com/dynamic/books/download.aspx to see the code available for this book and all other Wrox books. Errata We make every effort to ensure that there are no errors in the text or in the code. However, no one is perfect, and mistakes do occur. If you find an error in one of our books, such as a spelling mistake or a faulty piece of code, we would be very grateful for your feedback. By sending in errata, you may save xxiv
  • 19. Introduction another reader hours of frustration, and at the same time you will be helping us provide even higher quality information. To find the errata page for this book, go to www.wrox.com and locate the title using the Search box or one of the title lists. Then, on the book details page, click the Book Errata link. On this page you can view all errata submitted for this book and posted by Wrox editors. A complete book list, including links to each book’s errata, is also available at www.wrox.com/misc-pages/booklist.shtml. If you don’t spot ‘‘your’’ error on the Book Errata page, go to www.wrox.com/contact/techsupport. shtml and complete the form there to send us the error you have found. We’ll check the information and, if appropriate, post a message to the book’s errata page and fix the problem in subsequent editions of the book. p2p.wrox.com For author and peer discussion, join the P2P forums at p2p.wrox.com. The forums are a Web-based system for you to post messages relating to Wrox books and related technologies and interact with other readers and technology users. The forums offer a subscription feature to e-mail you topics of interest of your choosing when new posts are made to the forums. Wrox authors, editors, other industry experts, and your fellow readers are present on these forums. At http://p2p.wrox.com you will find a number of different forums that will help you not only as you read this book, but also as you develop your own applications. To join the forums, just follow these steps: 1. Go to p2p.wrox.com and click the Register link. 2. Read the terms of use and click Agree. 3. Enter the required information to join as well as any optional information you wish to pro- vide and click Submit. 4. You will receive an e-mail with information describing how to verify your account and com- plete the joining process. You can read messages in the forums without joining P2P but in order to post your own messages, you must join. Once you join, you can post new messages and respond to messages other users post. You can read messages at any time on the Web. If you would like to have new messages from a particular forum e-mailed to you, click the Subscribe to this Forum icon by the forum name in the forum listing. For more information about how to use the Wrox P2P, be sure to read the P2P FAQs for answers to questions about how the forum software works, as well as many common questions specific to P2P and Wrox books. To read the FAQs, click the FAQ link on any P2P page. xxv
  • 20. What Is Windows PowerShell? Windows PowerShell is the extensible command-line interface shell and scripting language that provides a command-line environment for interactive exploration and administration of computers. In addition, it provides developers with an opportunity to script these commands, enabling them to be automated, scheduled, and run multiple times. This chapter covers the following topics: ❑ A brief overview of command-line interfaces ❑ Prerequisites for installing PowerShell ❑ Installing PowerShell 2.0 CTP3. Command-Line Interfaces versus Graphical User Interfaces Before UNIX, Linux, and Windows surfaced in the information technology market, input media such as punched card and punched tape were used. All the input and instructions to the computer used command lines. When UNIX and Linux were released, administrators started managing the operating system using command-line interfaces, which were also used by the day-to-day users and programmers to inter- act with the operating system. UNIX and Linux are built on command-line interfaces, so there has always been administrative scripting and different shells, such as the Korn shell, the C shell, and the Bourne shell. Programming languages such as TCL and PERL were immediately available.
  • 21. Chapter 1: What Is Windows PowerShell? Originally, when Microsoft released MS-DOS, it was not used as a shell. It was entirely a standalone operating system. The initial and original Microsoft Windows release was a graphical shell that sat on top of the MS-DOS operating system. Once Windows NT was introduced, this situation was reversed. MS-DOS became the shell in the graphical Windows operating system. Graphical user interfaces (GUIs) were basically developed for users with less technical background who were looking for a friendly interface. Because graphical interfaces are limited to fewer functions, once you hit their limitations you will start relying on the command-line interface. For example, with a GUI, if you want to rename all the extensions of a group of files and suffix each file with the current day’s timestamp, it will take a while because you have to select and rename each file individually. Therefore, command-line interfaces and their commands are very commonly used for administrative tasks and automation. They also help to consolidate functionality in batches, through MS-DOS batch files. command.com was used as the command-line user interface in early versions of Microsoft Windows. cmd.exe was introduced in Windows NT. When administrators reached the limit of command-line batch files, they started looking for a language that could do both command shell functions and programming. Microsoft introduced the Visual Basic scripting language, which helped administrators initially. However, there were limitations in VBScript as well. Administrators started relying on Windows Management Instrumentation (WMI) and COM objects introduced later by Microsoft for many other administrative functions. The administrative command-line interface started becoming more complicated with internal DOS com- mands, external DOS commands, batch files, executables, VBScripts, WMI, and so forth. It was with all of this in mind that Microsoft developed and introduced Windows PowerShell. Prerequisites for Installing Windows PowerShell 2.0 Windows PowerShell can be installed and run on Windows XP, Windows Vista, Windows Server 2003, and Windows Server 2008. Although Windows PowerShell is included as part of Windows Server 2008, it is not installed by default on Windows XP, Windows 2003, or Windows Vista. At the time of writing, Windows PowerShell 1.0 is visible as a feature in Windows Server 2008 that can be turned on. Windows PowerShell 1.0 is also installed with Exchange Server 2007, System Center Operations Manager 2007, System Center Data Protection Manager V2, and System Center Virtual Machine Manager because they leverage Windows PowerShell to improve administrator control, efficiency, and productivity. This book uses Windows PowerShell 2.0 CTP3. Before installing Windows PowerShell 2.0 CTP3, you should ensure that your system has the following software programs it requires: ❑ Windows XP Service Pack 3, Windows 2003 Service Pack 2, Windows Vista Service Pack 1, or Windows Server 2008 ❑ Microsoft .NET Framework 2.0 or greater 2
  • 22. Chapter 1: What Is Windows PowerShell? ❑ Windows Remote Management 2.0 CTP3 for Windows PowerShell remoting and background jobs ❑ Microsoft .NET Framework 3.5 Service Pack 1 for Windows PowerShell Integrated Scripting Environment (ISE) and the Out-GridView cmdlet If .NET Framework 2.0 is not installed on your computer, the error message shown in Figure 1-1 will pop up when you try to install Windows PowerShell 2.0 CTP3. Figure 1-1 After installing the .NET Framework, if you continue to install on a non-standard operating system such as Windows Server 2000, Windows NT, and so on, you may get the error shown in Figure 1-2. Figure 1-2 Although Figure 1-2 shows v1.0 in the title bar and file path, it is actually PowerShell 2.0 CTP3. Com- munity Technology Preview, also known as CTP3, is basically the bug fix that Microsoft relies on, adding new features based on feedback from the technology community. The folder may be changed to v2.0 once the release to manufacturing (RTM) version is released. In order to check the prerequisites for the PowerShell installation, we created a batch file to run all the necessary checks. Listing 1-1 shows the MS-DOS batch script, CheckPowershellPreqs.bat, which uses Windows Management Instrumentation Command-line (WMIC) to check the requirements before you install Windows PowerShell. WMIC enables you to access WMI information via the command line. In some respects, you can think of WMIC as an early prototype of PowerShell. However, WMIC can only output its results as text. It doesn’t return programming objects that can be further processed, as Window PowerShell does, and as you will see later. Listing 1-1: CheckPowershellPreqs.bat @ECHO Off REM ***************************************************************** REM *Objective: TO check if the current windows version is * REM * Compatible for PowerShell 2.0 and its pre-requisites* REM *Created by: Yan and MAK * REM *Created Date: 2008/09/01 * Continued 3
  • 23. Chapter 1: What Is Windows PowerShell? Listing 1-1: CheckPowershellPreqs.bat (continued) REM * * REM ***************************************************************** SET OS_VERSION= SET Service_Pack= REM Find OS version FOR /F "delims== tokens=2" %%i IN (’wmic os get Version /value’) DO SET OS_VERSION=%%i IF NOT DEFINED OS_VERSION ( ECHO WMIC is not installed on this system. GOTO :END_SCRIPT ) REM Find service pack value FOR /F "delims== tokens=2" %%i IN (’wmic os get ServicePackMajorVersion /value’) DO SET Service_Pack=%%i REM Windows XP IF "%OS_VERSION%"=="5.1.2600" ( @IF "%Service_Pack%" LSS "3" ( ECHO %OS_NAME% Service Pack 3 is required GOTO :END_SCRIPT ) GOTO :DOTNETFRAMEWORK_CHECK ) REM Windows Server 2003 IF "%OS_VERSION%"=="5.2.3790" ( @IF "%Service_Pack%" LSS "2" ( ECHO %OS_NAME% Service Pack 2 is required GOTO :END_SCRIPT ) GOTO :DOTNETFRAMEWORK_CHECK ) REM Windows Vista IF "%OS_VERSION%"=="6.0.6001" ( @IF "%Service_Pack%" LSS "1" ( ECHO %OS_NAME% Service Pack 1 is required GOTO :END_SCRIPT ) GOTO :DOTNETFRAMEWORK_CHECK ) IF "%OS_VERSION%" GTR "5.2.3790" ( GOTO :DOTNETFRAMEWORK_CHECK ) ELSE ( GOTO :END_SCRIPT ) 4
  • 24. Chapter 1: What Is Windows PowerShell? Listing 1-1: CheckPowershellPreqs.bat (continued) REM Check .NET framework :DOTNETFRAMEWORK_CHECK wmic product where (caption like "Microsoft .NET Framework%%") get Version /value | findstr "=[2-9].*" > nul IF "%ERRORLEVEL%"=="1" ( ECHO .NET Framework 2.0 or greater is required GOTO :END_SCRIPT ) REM Check Windows remote management :WINRMCHECK wmic path Win32_service where caption="Windows Remote Management (WS-Management)" | findstr /i "(WS-Management)" > nul IF "%ERRORLEVEL%"==1 ( ECHO Windows Remote Management is required GOTO :END_SCRIPT ) ECHO Your system meets the requirements :END_SCRIPT From a Windows command console, run CheckPowershellPreqs.bat from the script directory C:DBAScripts. You should get a message similar to the one shown in Figure 1-3 if your system meets the requirements for a PowerShell installation. Figure 1-3 You may run into an error as follows on Windows Server 2003: ERROR: Code = 0x80041010 Description = Invalid class Facility = WMI This means that you need to install the WMI Windows Installer Provider in order for WMIC to work. To do so, open Control Panel Add/Remove Programs. Select Add/Remove Windows Components. Double-click Management and Monitoring Tools. Select WMI Windows Installer Provider, and then click OK to install. If your operating system is Windows XP Service Pack 2 and you install Windows PowerShell 2.0 CTP3, it may or may not work. The officially supported service pack for Windows XP when installing Windows 5
  • 25. Chapter 1: What Is Windows PowerShell? PowerShell 2.0 CPT3 is Service Pack 3, so when executing C:DBAScriptsCheckPowershellPreqs.bat it will complain that Service Pack 3 is required. Installing the Microsoft .NET Framework Windows PowerShell integrates with the .NET Framework and provides a shell environment to per- form administrative tasks. PowerShell exposes the .NET classes as built-in commands, and when these commands are executed they produce one or more structured objects as output. Download the .NET Framework from http://download.microsoft.com and install .NET Framework 2 or later. It is recommended that you use .NET 3.5, although all the code in this book works on .NET Framework 2 and later. In Chapter 11, you will see that an SQL Server 2008 installation installs .NET 3.5 by default. Installing Windows Remote Management Another prerequisite is to install Windows Remote Management (WinRM). WinRM is required for Win- dows PowerShell remoting and background jobs. You can download WinRM 2.0 CTP3 (also known as Ws-Management) from https://connect.microsoft.com/WSMAN/Downloads for Windows Vista and Windows Server 2008. The installation procedures of the executable Windows6.0-KB950099-x86.msu for 32-bit and Windows6.0-KB950099-x64.msu for 64-bit are shown in Figure 1-4 and Figure 1-5. Figure 1-4 Figure 1-5 6
  • 26. Chapter 1: What Is Windows PowerShell? Double-click on Windows6.0-KB950099-x86.msu if you are installing WinRM on a 32-bit Windows oper- ating system. Double-click on Windows6.0-KB950099-x64.msu if you are installing it on a 64-bit Windows operating system. If you already have Windows PowerShell 1.0 installed on your machine, then you have to uninstall PowerShell 1.0 first and then install PowerShell 2.0 CTP3. To uninstall Windows PowerShell 1.0, follow these steps: 1. Click Start ➪ Run, type appwiz.cpl, and then click OK. 2. Select the Show Updates check box (on the top in the middle). 3. In the list of currently installed programs, click Windows PowerShell(TM) 1.0, and then click Remove. If you don’t see Windows PowerShell(TM) 1.0, please look for Windows Hotfix 926139, 926140, or 926141. 4. Follow the instructions to remove Windows PowerShell(TM) 1.0. If you already have Windows PowerShell 2.0 CTP1 or CTP2, you have to uninstall them also. They appear as ‘‘Windows PowerShell V2 (TM)’’ in the program list. In Windows 2008, Windows PowerShell 1.0 is made visible as a Windows feature. You can disable and uninstall the PowerShell feature as described here: 1. Click Start at the Windows taskbar. 2. Click Server Manager Features Add Feature, and uncheck the Windows PowerShell check box. 3. Click Next to uninstall. Now that you have the acceptable operating system, the .NET Framework, and Windows Remote Man- agement, the next section provides the steps needed to actually install Windows PowerShell 2.0 CTP3. Installing Windows PowerShell To install Windows PowerShell on Windows XP or Windows 2003 systems, do the following: 1. Download the Windows PowerShell 2.0 CTP3 installation file from www.Microsoft.com/ downloads. The name of the installation file varies according to platform, operating system, and language pack. Choose the appropriate version for your operating system. If you have a 64-bit Windows operating system, then please download PowerShell_Setup_amd64.msi, as shown in Figure 1-6. If you have a 32-bit Windows operating system, then please download PowerShell_Setup_x86.msi, as shown in Figure 1-7. 2. After downloading the appropriate version for your operating system, you will see the ini- tial screen of the installation wizard, similar to the one shown in Figure 1-8. Click Next. 3. Accept the license agreement, as shown in Figure 1-9, and click Next. 7
  • 27. Chapter 1: What Is Windows PowerShell? Figure 1-6 Figure 1-7 Figure 1-8 8
  • 28. Chapter 1: What Is Windows PowerShell? Figure 1-9 4. It takes a few minutes to complete the install. As shown in Figure 1-10, click Install to begin the installation process. You will see the progress of the installation, as shown in Figure 1-11. Figure 1-10 5. When installation is completed successfully, you will see a screen similar to the one shown in Figure 1-12. Click Finish. On 32-bit versions of Windows, Windows PowerShell is installed by default in the %SystemRoot% System32WindowsPowerShellv1.0 directory. On 64-bit versions of Windows, a 32-bit version of Windows PowerShell is installed in the %SystemRoot%SystemWow64WindowsPowerShellv1.0 directory and a 64-bit version of Windows PowerShell is installed in the %SystemRoot%System32WindowsPowerShellv1.0 directory. 9
  • 29. Chapter 1: What Is Windows PowerShell? Figure 1-11 Figure 1-12 This book covers Windows PowerShell 2.0 CTP3. The installation file replaces the executables in the v1.0 folder. The actual folders for Windows PowerShell may change to v2.0 when PowerShell 2.0 RTM is released. Launching Windows PowerShell Windows PowerShell can be launched in several ways. This section describes the different methods. No method is superior to the others. It is just a matter of preference. 10
  • 30. Chapter 1: What Is Windows PowerShell? Using the Command console To launch Windows PowerShell using the command console, open the command console and then type powershell, as shown in Figure 1-13. Figure 1-13 Using All Programs You can also click Start All Programs Windows PowerShell V2 (CTP3), and then select and click Windows PowerShell V2 (CTP3), as shown in Figure 1-14. Figure 1-14 You may also see Windows PowerShell ISE (CTP3) in the Windows Program menu. The Windows Power- Shell Integrated Scripting Environment (ISE) is a host application for Windows PowerShell. In Windows PowerShell ISE, you can run commands and write, test, and debug scripts in a single Windows graph- ical user interface. This book illustrates all Windows PowerShell-related cmdlets and scripts using a command-line interface. It does not illustrate PowerShell scripts using the ISE. Once PowerShell is launched, you can see the command prompt. The prompt in the PowerShell com- mand window varies according to the operating system used. To be consistent with the PowerShell window title, you could update the shortcut, as illustrated in Figure 1-15. Right-click on the Windows PowerShell V2 (CTP3) shortcut, click Properties, and under the General tab, update the title to ‘‘Windows PowerShell’’ and click OK. Using Start Run You can also launch PowerShell by clicking Start Run and typing the following: %systemroot% system32windowsPowerShellv1.0PowerShell.exe. Then click OK, as shown in Figure 1-16. 11
  • 31. Chapter 1: What Is Windows PowerShell? Figure 1-15 Figure 1-16 Alternatively, you can also launch PowerShell by clicking Start Run and typing PowerShell. Windows finds the PowerShell.exe executable from the environment PATH variable and then launches it. This opens the PowerShell command console, shown in Figure 1-17. Figure 1-17 12
  • 32. Chapter 1: What Is Windows PowerShell? If you are using 64-bit PowerShell, then you can launch PowerShell by clicking Start Run and typing the following: %systemroot%SysWOW64WindowsPowerShellv1.0PowerShell.exe. Then click OK, as shown in Figure 1-18. Figure 1-18 This opens the PowerShell command console, as shown in Figure 1-19. Figure 1-19 Summary This chapter discussed the prerequisites for Windows PowerShell, described how to install Windows PowerShell 2.0 CTP3, and showed various methods to launch PowerShell. The next chapter covers the various command types and commonly used cmdlets that appear throughout the book. A Windows PowerShell cmdlet is a simple command used for interaction with any managed application, including the Windows operating system and applications such as SQL Server, Microsoft Exchange, and so on. 13
  • 33. Windows PowerShell Command Types, Snap-ins, and cmdlets Now that you’ve installed Windows PowerShell on your computer, I bet you can’t wait to start run- ning your own commands to unravel the power of Microsoft’s new command shell. This chapter introduces you to the new PowerShell commands, or cmdlets. It also introduces you to the collec- tions of cmdlets called snap-ins. By following all of the examples in this book, you will become comfortable working with the cmdlets, and you will even be able to tweak the output to your liking. First, however, this chapter gives you a quick-start on how to run PowerShell commands interactively. This chapter covers the following topics: ❑ PowerShell command types ❑ PowerShell snap-ins ❑ Syntax of cmdlets ❑ Command chaining ❑ Getting help ❑ Filtering ❑ Sorting ❑ Formatting
  • 34. Chapter 2: Command Types, Snap-ins, and cmdlets PowerShell Command Types When you launch a new PowerShell window, you are basically executing a small PowerShell.exe executable, which provides a command-line interface and issues instructions on how to make the func- tionality in the PowerShell Engine available. Those instructions are written in .NET language and are available in the form of commands called cmdlets (pronounced ‘‘command lets’’). All the cmdlets, when executed, process the instructions and return an object, not just text. The following four different command types are available in the PowerShell environment. Don’t panic. PowerShell understands and performs the different types of functions based on the type of commands that you execute. ❑ Native commands ❑ PowerShell cmdlets ❑ Shell functions ❑ Script commands The following sections take a closer look at the differences between the different command types in PowerShell and how each can be used. Native Commands Native commands are external executables that the Windows operating system can run. For example, notepad.exe, calc.exe, or even a batch file can be run from the PowerShell command-line interface. The following example executes a Windows command shell cmd.exe with the system.ini file as a parameter, as shown in Figure 2-1: cmd /c c:windowssystem.ini Figure 2-1 Once this command is executed, PowerShell recognizes the executable file and passes the command to the operating system directly. The operating system basically opens the file using the default editor Notepad.exe, as shown in the Figure 2-2. If the default editor on your machine is not Notepad.exe, then the operating system opens this exe- cutable file with your default editor, rather than Notepad.exe. 16
  • 35. Chapter 2: Command Types, Snap-ins, and cmdlets Figure 2-2 The next example will launch the Windows calculator. Enter the following command into PowerShell, as shown in Figure 2-3: calc Figure 2-3 Once this command is executed, PowerShell recognizes the executable file and passes the command to the operating system directly. The operating system launches the calculator, as shown in Figure 2-4. Figure 2-4 You can also execute a batch file within the Windows PowerShell environment. Create a small batch file, C:Batch-Test.bat, that displays the current date and time, as shown here: @Echo off Echo The current date is : %date% Echo The current time is : %time% 17
  • 36. Chapter 2: Command Types, Snap-ins, and cmdlets You can execute the batch file in the Windows PowerShell environment using . or ./, as shown in Figure 2-5: .Batch-Test.bat Figure 2-5 PowerShell cmdlets PowerShell cmdlets are compiled DLL files that are loaded into PowerShell at runtime. Anybody can write custom cmdlets using the PowerShell Software Development Kit (SDK). You can get more information on the PowerShell SDK from http://msdn.microsoft.com/en-us/library/ms714469 (VS.85).aspx. The cmdlets are constructed in verb-noun format. The verb specifies the action that it is going to perform and the noun specifies the object being operated on. The noun is always singular (not plural), even if it retrieves or acts on multiple objects. The following example is a cmdlet that gets all the processes running on the current host machine, as shown in Figure 2-6: Get-Process Figure 2-6 The term get in this command is the verb, and the term process is the noun, so the cmdlet ‘‘gets’’ all the ‘‘processes’’ running on the current host. Amazing, isn’t it? You don’t have to use VBScript to query the WMI win32 process class and get the process information and format the result. Just a simple Get-Process command will do that for you. 18
  • 37. Chapter 2: Command Types, Snap-ins, and cmdlets We know this makes you wonder what other amazing cmdlets are available that you could use in your environment. If you would like to know the basic definitions of cmdlets and other elements of all the PowerShell commands in the current PowerShell environment, you can run the following cmdlet, as shown in Figure 2-7: Get-Command Figure 2-7 Figure 2-7 shows the names of the cmdlets and their definitions. Windows PowerShell 2.0 CTP3 also has a feature called Tab Completion. With this feature, you don’t have to type the entire cmdlet every time it is used. You can just type the beginning of the cmdlet — for example, Get-PS, and press the Tab key. PowerShell will automatically complete your cmdlet with the cmdlet starting with Get-PS. If more than one cmdlet starts with Get-PS, then press the Tab key again and PowerShell will show you the next available cmdlet that starts with Get-PS. Continue pressing the Tab key until you see the cmdlet that you want to use. For example, if you type Get-PS and press the Tab key several times, all of the following cmdlets will appear, in ascending order: ❑ Get-PSBreakpoint ❑ Get-PSCallStack ❑ Get-PSDrive ❑ Get-PSProvider ❑ Get-PSSession ❑ Get-PSSessionConfiguration ❑ Get-PSSnapin Shell Function Commands Shell function commands are subroutines that you can create and have available throughout the current PowerShell session. If a block of code is often re-used in the main code, then you can create a function and call the function wherever necessary within the main code. 19
  • 38. Chapter 2: Command Types, Snap-ins, and cmdlets Here is an example of how to create a simple function. This function lists all the files with the extension .ini under the C:Windows folder. Shell functions are discussed in more detail in Chapter 4. function list-ini {Get-ChildItem c:windows*.ini} Once the preceding command is executed (see Figure 2-8), the function list-ini is created. Figure 2-8 This list-ini function can be called anywhere in the current session. Execute the function as shown in Figure 2-9. Once the function name is called, PowerShell recognizes it as a function code block and executes the code block defined in the actual function list-ini. The following command requests all the files with the extension .ini under C:Windows folder: list-ini Figure 2-9 Functions can be made persistently available in all the Windows PowerShell sessions by adding them to the PowerShell profile. You will see examples of the Windows PowerShell profile and its uses in detail in Chapter 5. Script Commands Script commands are a set of executable PowerShell cmdlets stored in a file with the .ps1 extension. You can create a simple Add-Num.ps1 script using Notepad under the directory C:DBAScripts, as shown in the following example. This script file, shown in Figure 2-10, accepts two variables, $variable1 and $variable2, as parameters and stores the sum to a third variable, $variable3. It then displays the value of $variable3. # ================================================== # # NAME: Add-Num.ps1 20
  • 39. Chapter 2: Command Types, Snap-ins, and cmdlets # # AUTHOR: Yan and MAK # DATE : 4/26/2008 # # COMMENT: This script accepts two numbers, sums the # two numbers and display the result # # ================================================== param ( [int] $variable1, [int] $variable2 ) $variable3=$variable1+$variable2; $variable3 You can use any text editor to write a PowerShell Script file, not just Notepad. Figure 2-10 Here, all the information that appears after the pound symbol (#) will be ignored by Windows PowerShell because that tells PowerShell that those are comments. Beginning with PowerShell 2.0 CTP3, you can use multi-line comments using # and #. Because you created the PowerShell script Add-Num.ps1 under C:DBAScripts, you have to navigate to the folder DBAScripts. The cmdlet Set-Location can be used to move the location from the current folder to the DBAScripts folder, as shown in Figure 2-11. Then the PowerShell script Add-Num.ps1 can be executed using . or ./, as shown in Figure 2-11. Set-Location C:DBAScripts .add-num.ps1 100 200 ./add-num.ps1 10 200 When executing the script, if PowerShell returns the warning message ‘‘Script cannot be loaded because execution of script is disabled,’’ then execute the following command, followed by the script shown in 21
  • 40. Chapter 2: Command Types, Snap-ins, and cmdlets Figure 2-11 Figure 2-12. By default, execution of any PowerShell script is restricted for security reasons, but you can use the cmdlet set-executionpolicy to make it unrestricted. Set-ExecutionPolicy Unrestricted Figure 2-12 More PowerShell scripts and securities are shown in detail in later chapters. Calling PowerShell cmdlets or Scripts from the Command Shell PowerShell functionality can be used from other shells such as command shell. The PowerShell.exe executable accepts numerous parameters, such as a console file or a command. You can execute .ps1 files by passing them as parameters to the PowerShell executable, as shown in Figures 2-13 and 2-14. Launch the command shell by running the following command from Start Run, as shown in Figure 2-13: cmd.exe At the command prompt, execute the following command as shown in Figure 2-14. This PowerShell.exe executable accepts the parameter name -command and the parameter value Add-Num.ps1 with parameters 100 and 400: PowerShell -command C:DBAScriptsadd-num.ps1 100 400 22
  • 41. Chapter 2: Command Types, Snap-ins, and cmdlets Figure 2-13 Figure 2-14 You can execute a PowerShell cmdlet directly from the command shell as shown here and in Figure 2-15: PowerShell -command Get-Process Figure 2-15 PowerShell Snap-ins PowerShell cmdlets are contained in PowerShell snap-ins. PowerShell snap-ins are a group of Power- Shell cmdlets or providers that extend the functionality of the shell. When a snap-in is loaded into the PowerShell environment, the cmdlets and providers contained in it are registered with the shell. By default, seven core snap-ins are loaded, and their corresponding cmdlets are available when Power- Shell is launched. Each core snap-ins has its own namespace: ❑ Core ❑ Host 23
  • 42. Chapter 2: Command Types, Snap-ins, and cmdlets ❑ Management ❑ Security ❑ Utility ❑ Diagnostics ❑ WSMAN.Management Execute the following PowerShell cmdlet to see all the snap-ins that are loaded into the current Power- Shell environment, as shown in Figure 2-16. Get-PSSnapin Figure 2-16 The following sections describe each of the snap-ins and their cmdlets. Most of the cmdlets listed here are described and demonstrated throughout the remaining chapters. The following section provides basic information about how to get all the cmdlets available in each snap-in. You can also check Appendix A for more details about each cmdlet in each snap-in. Core The namespace of the Core snap-in is Microsoft.PowerShell.core. This snap-in contains cmdlets related to the PowerShell engine, such as aliases, environments, variables, and functions. You can find all the cmdlets available in the namespace Microsoft.PowerShell.core using the simple cmdlet shown in Figure 2-17. 24
  • 43. Chapter 2: Command Types, Snap-ins, and cmdlets Here, two cmdlets are used. One is Get-Command, which provides the commands available in Power- Shell. The other is Where-Object, which is used for filtering the result. The pipe (|)is used for command chaining. More about command chaining is explained later in this chapter. Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match core} Figure 2-17 Host The namespace of the Host snap-in is Microsoft.PowerShell.Host. This snap-in contains cmdlets related to hosting, such as start-transcript and stop-transcript. You can find all the cmdlets available in the namespace Microsoft.PowerShell.host using the following cmdlet, shown in Figure 2-18: Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match host} Figure 2-18 PowerShell.Management The namespace of the Management snap-in is Microsoft.PowerShell.Management. This snap-in contains cmdlets related to windows management, such as managing services and processes, and so on. 25
  • 44. Chapter 2: Command Types, Snap-ins, and cmdlets You can find all the cmdlets available in the namespace Microsoft.PowerShell.Management using the following cmdlet, shown in Figure 2-19: Get-Command –commandtype cmdlet | Where-Object {$_.PSSnapin -match PowerShell.Management} Figure 2-19 Security The namespace of the Security snap-in is Microsoft.PowerShell.Security. This snap-in contains cmdlets related to PowerShell security, such as Get-Acl and Set-ExecutionPolicy. You can find all the cmdlets available in the namespace Microsoft.PowerShell.Security using the follow- ing cmdlet: Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match Security} Figure 2-20 shows some of the commonly used cmdlets, including their descriptions, related to the Secu- rity snap-in. Figure 2-20 26
  • 45. Chapter 2: Command Types, Snap-ins, and cmdlets Utility The namespace of the Utility snap-in is Microsoft.PowerShell.Utility. This snap-in contains cmdlets that can retrieve and manipulate data, such as write-host, Format-List, and so on. You can find all the cmdlets available in the namespace Microsoft.PowerShell.Utility using the following cmdlet: Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match Utility} Figure 2-21 shows some of the commonly used cmdlets, including their descriptions, related to the Utility snap-in. Figure 2-21 Diagnostics The namespace of the Diagnostic snap-in is Microsoft.PowerShell.Diagnostics. This snap-in contains cmdlets related to performance counters and event logs. You can find all the cmdlets available in the namespace Microsoft.PowerShell.Diagnostics using the following cmdlet, shown in Figure 2-22: Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match Diagnostics} Figure 2-22 27
  • 46. Chapter 2: Command Types, Snap-ins, and cmdlets WsMan.Management The namespace of the WsMAN.Management snap-in is Microsoft.WsMan.Management. This snap-in contains cmdlets related to WsMan. You can find all the cmdlets available in the namespace Microsoft.WsMan.Management using the follow- ing cmdlet, shown in Figure 2-23: Get-Command -commandtype cmdlet | Where-Object {$_.PSSnapin -match WsMan.Management} Figure 2-23 cmdlets related to WsManagement are very new and currently there is little documentation for Power- Shell 2.0 CTP3. This should change, however, after its official release. Such documentation, when it becomes available, will help you understand more about each of the cmdlets and enable you to explore their functionality and usage. PowerShell cmdlet Syntax As stated earlier in this chapter, cmdlets are constructed in verb-noun format. The verb specifies the action to be performed and the noun specifies the object being operated on. Recall that the noun is always singular, even if it retrieves or acts on multiple objects or data. Two examples are the cmdlet Get-process and Write-host. Most cmdlets accept parameters. All parameters names are prefixed with a hyphen, and all the parameter values are prefixed with a blank space after the parameter name. There are two types of parameters: named parameters and positional parameters. Named Parameter This is the easiest and most common way to use parameters. Basically, you specify the name of the parameter followed by its value — for example, Get-Process –Name smss: Get-Process –Name smss 28
  • 47. Chapter 2: Command Types, Snap-ins, and cmdlets Get-process is the cmdlet, Name is the parameter name, and smss is the parameter value. Parameter values can be substituted with wildcards as well, as shown here and in Figure 2-24: Get-Process –Name s* Figure 2-24 Positional Parameter PowerShell allows us to omit the parameter name completely for certain parameters. In the previous example, name is a positional parameter in the first position; therefore, it can be called without the param- eter name (see Figure 2-25), as shown here: Get-Process s* Figure 2-25 You can easily find all the positional parameter of a PowerShell cmdlet by executing the following cmdlet (see Figure 2-26): (Get-Help Get-Process).parameters.parameter 29
  • 48. Chapter 2: Command Types, Snap-ins, and cmdlets Figure 2-26 Figure 2-26 shows the end of the output. As you can see, the value of the Position? property of the Name parameter is 1, so Name is a positional parameter at position 1. Windows PowerShell supports the following six common parameters on all the cmdlets: ❑ Debug ❑ ErrorAction ❑ ErrorVariable ❑ OutputBuffer ❑ OutputVariable ❑ Verbose Two other commonly used parameters available in certain cmdlets provide options for ‘‘what if’’ scenar- ios and choosing confirmation (Yes/No): ❑ WhatIf ❑ Confirm For more information regarding the common parameters, run the following command: Get-Help about_CommonParameters Command Chaining As in UNIX and Linux, PowerShell cmdlets can be chained together using a pipeline. Command chaining is having the output of one command feed into, or act as the input to, another command. This was shown earlier in Figure 2-23. In the following command example, the output of Get-Process is fed to the cmdlet Where-Object. The output of the cmdlet Where-Object is fed to the cmdlet Sort-Object. As you already know, the cmdlet Get-Process shows all the processes on the current local machine. When the output of the Get-Process is fed to Where-Object using command chaining, the Where-Object processes each item from the output of Get-Process and looks for the processname equal to the value 30
  • 49. Chapter 2: Command Types, Snap-ins, and cmdlets rundll32. Then the filtered output of Where-Object is passed to Sort-Object, which sorts the database based on the Object ID value in descending order (see Figure 2-27). Get-Process | Where-Object {$_.Processname -eq rundll32} | Sort-Object ID –desc Figure 2-27 Hence, the output shown in Figure 2-27 is the result of command chaining. You will be using command chaining throughout this book. Getting Help Microsoft documented all the cmdlets and that documentation can be retrieved using the cmdlet Get- Help. This documentation is similar to using the man command in the UNIX and Linux environment. In addition, certain parameters can be used with Get-Help to get detailed information and examples. The cmdlet Get-Help can be used in three different ways: ❑ Get-Help with no parameter: Get-Help Get-Process This provides the minimal information needed to understand and use the cmdlet. The following information is returned when executed (see Figure 2-28): ❑ Name ❑ Synopsis ❑ Detailed Description ❑ Related Links ❑ Remarks ❑ Get-Help with the –detailed parameter: Get-Help Get-Process –detailed 31
  • 50. Chapter 2: Command Types, Snap-ins, and cmdlets Figure 2-28 This returns the following information when executed (see Figure 2-29): ❑ Name ❑ Synopsis ❑ Syntax ❑ Detailed Description ❑ Parameters ❑ Examples ❑ Remarks Figure 2-29 ❑ Get-Help with the –full parameter: Get-Help Get-Process –full This provides all of the following (see Figure 2-30): ❑ Name ❑ Synopsis 32
  • 51. Chapter 2: Command Types, Snap-ins, and cmdlets ❑ Syntax ❑ Detailed Description ❑ Parameters ❑ Input Types ❑ Return Type ❑ Notes ❑ Examples ❑ Related Links Figure 2-30 When using the -full and -detailed parameters, the documentation expands to several pages and flashes through screen and it is very difficult to read all of them if you do not have enough screen buffer. You can use command chaining with the MS-DOS executable more to page the documentation, as shown here: Get-Help Get-Process -Full | more This causes the output to be displayed one screen at a time. You can scroll the pages from one screen to another by pressing the spacebar or Enter key. You can abort the display of paging using Ctrl + C. Figure 2-31 shows the same Get-Help Get-Process cmdlet using more. Figure 2-31 33
  • 52. Chapter 2: Command Types, Snap-ins, and cmdlets Alternatively, you can just use the built-in Help function. The Help function actually pipes the result from the Get-Help cmdlet to more to support paging, as shown in the following example: Help Get-Process -Full Filtering The cmdlets can produce humongous results. Not all of the columns and rows that are displayed as output are useful all the time. You may need to filter the results. PowerShell provides two cmdlets for filtering: Where-Object and Select-Object. As shown earlier when you ran the Get-Process cmdlet, it returns all the processes running on the current host (see Figure 2-32): Get-Process Figure 2-32 If, for example, you’re only interested in the processes that start with ‘‘s’’, then you can use the Where- Object cmdlet as shown here and in Figure 2-33: Get-Process | Where-Object {$_.Processname -like s*} Figure 2-33 34
  • 53. Chapter 2: Command Types, Snap-ins, and cmdlets Basically, $_ is substituted with the actual output of Get-Process row by row and evaluated against the –like operator with the value s*. If you want to list all the processes that start with ‘‘s’’ excluding the process name svchost, then you can use the and and ne operators in the Where-Object, as shown here (see Figure 2-34): Get-Process | Where-Object {$_.Processname -like s* –and $_.Processname –ne svchost } Figure 2-34 The following table shows the comparison operators available in PowerShell. Comparison Operator Meaning Example (returns true) -eq Is equal to 1 -eq 1 -ne Is not equal to 1 -ne 2 -lt Is less than 1 -lt 2 -le Is less than or equal to 1 -le 2 -gt Is greater than 2 -gt 1 -ge Is greater than or equal to 2 -ge 1 -like Is like (wildcard comparison for text) file.doc -like f*.do? -notlike Is not like (wildcard comparison for text) file.doc -notlike p*.doc -contains Contains 1,2,3 -contains 1 -notcontains Does not contain 1,2,3 -notcontains 4 -ceq Case sensitive equal to a -ceq a -cne Is not equal to a -cne A 35
  • 54. Chapter 2: Command Types, Snap-ins, and cmdlets The next table shows the logical operators available. Logical Operator Meaning Example (returns true) -and Logical and; true if both sides are true (1 -eq 1) -and (2 -eq 2) -or Logical or; true if either side is true (1 -eq 1) -or (1 -eq 2) -not Logical not; reverses true and false -not (1 -eq 2) ! Logical not; reverses true and false !(1 -eq 2) You can also filter items up front in the Get-Process itself, as shown here and in Figure 2-35: Get-Process s* | Where-Object {$_.Processname -ne svchost} Figure 2-35 If the operator needs to use numerical values, then you can use numerical operators, as shown here and in Figure 2-36: Get-Process | Where-Object {$_.Handles -gt 1100 -and $_.CPU -gt 5} Figure 2-36 36
  • 55. Random documents with unrelated content Scribd suggests to you:
  • 56. Vai sillä tavalla! Voi sentään, etten minä juopporaukka ole kyllin hyvä lähestymään sellaista Jumalan enkeliä! — Lapikas-Pekka kääntyi äkkiä lapsista, ja palasi yksin tyhjään, mutta nyt niin siistiin tupaansa. Hän istui takan ääreen ja nyyhkytti niinkuin kaikki elämänilo olisi häneltä paennut. Halli, joka oli tyytyväisenä nähnyt vastenmielisen seuran lähtevän tiehensä ja ulkona pikkuportaalta iloisesti heiluttanut jäähyväisiä hännällään, vinkui nyt surkeasti ja osaaottaen tavatessaan isännän tuvassa niin raskaalla mielellä. Seitsemäs luku. HAJALLAAN. Lapsijoukon kulku suuren tunturikylän läpi ei herättänyt erikoisen suurta huomiota väestössä. Liiankin usein nähtiin näinä aikoina kokonaisten nälistyneitten perhekuntienkin lähtevän kerjäämään elatustaan. Hallantunturin lapset vaelsivat Lapikas-Pekan neuvosta suoraan virran partaalle päin. Aluksi he olivat pelokkaita ja allapäin ja puhuivat kaipauksella silmälasimiehestä. Mutta oli sentään niin ihanaa, kun oli paljon lunta, ja niin vapaata ja hauskaa oli päästä ulkoilmaan, että he lopullisesti tunsivat itsensä oikein tyytyväisiksi ja hilpeiksi aamurupeamassa. Ilma selkeni, ja kinokset seisoivat korkeina valleina pitkin tien syrjää. Nuo raskaat kinokset olivat niin lystikkään näköisiä. Ne olivat ripustautuneet
  • 57. kattojen päälle kuin paksut, valkoiset vällyt, jotka riippuivat vasten ikkunoita. Katajilla ja pikkukuusilla oli latvassaan korkeita, hupaisia piippalakkeja, ja pitkin vanhoja aitoja laskeutuivat kinokset kuin paksut, valkovillaiset vaatteet. — Niin, että olipa paljon hauskaa nähtävää tänäpäivänä. Punaisista kaksikerroksisista taloista ja pienistä, harmaista tuvista he eivät niin paljoa välittäneet. Niissä oli kaikki jotenkin samannäköistä kuin kotona omassa pitäjässä. Naisväki kahlasi polvia myöten lumessa päästäkseen navettoihin, jotka olivat vaipuneet valkoisiin kinoksiin; lapset lakaisivat ja lapioivat portaita ja polkuja, ja miehet askaroitsivat ajokaluineen ja valmistautuivat metsälle hirrenajoon. Puolipäivään päästessä menivät lapset ison kylän päässä olevaan suurtaloon. Ruokaa he saivat siellä, leipää ja keitettyä silakkaa. Astiallinen kirnupiimää pantiin myös heidän eteensä uuninpenkille. Mutta he läksivät sieltä äänettöminä ja alakuloisina. Emäntä, joka oli heille Jumalan lahjan antanut, oli näyttänyt niin tuimalta, heittänyt ruuan heille ja mutissut — mutta niin että kaikki kuulivat — että tunturilta tulevat kerjäläiset söivät kohta koko talon putipuhtaaksi. Isäntä, joka oli tullut sisään ja nähnyt heidän syövän rivissä uuninpenkin ääressä, oli sanonut, että tuollainen joukko sopisi parhaiten köyhäintaloon, ja että elleivät hänen hevosensa olisi kiinni metsäajoissa, tekisi hän viisaimmin toimittaessaan heille paluukyydin sinne. Talon lapset olivat näyttäneet niin jöröiltä ja happamilla kuin olisivat asuneet köyhäinhuoneella sen sijaan että elivät suuressa talossa, missä oltiin niin rikkaita, että siellä hyllyllä oven päällä oli kuusi kuparikattilaa, ja koreita kaappeja ja kokonainen rivi hopealusikoita ylinnä kaapinhyllyllä.
  • 58. Vaikka siellä oli hienoa, oli Pekan tuvassa mielestäni koreampaa, sanoi Mauno. Kas se oli mies, se. Koreampaa ei ollut, väitti Anna-Liisa. Olikos sekin laitaa miten kamalalta siellä näytti tullessamme: lattia likainen ja takka musta, se ei tainnut olla vuosikausiin valaistu, ja ikkunanlasi niin ettei läpi näkynyt, ja lakanat ja pieluksen päälliset ylen ruskeita, ennenkuin saimme ne pestyiksi. Ei, koreampaa ei siellä ollut. Nytkään ei siellä ole koreampaa, vaikka lattia on valkoinen, ja matot lattialla, ja takka hieno, ja ikkunanlasi kirkas, sikäli kuin minä ymmärrän. Anna-Liisa katseli epätietoisen ja hämmästyneen näköisenä eteensä. Niin, en minäkään ymmärrä, tunnusti Antti. Me saimme heidän luonansa leipää paremmista jauhoista, ja valoisaa ja koreaa siellä oli, ruokaa me saimme, ja kumminkin olen aivan kuin kiukuissani heille. Äiti sanoi, ettemme saisi olla kiukuissamme, Antti. Ei, en minä ole vihainen, sanoi Matleena, mutta kun ajattelen heitä, niin oikein pelkään ihmisiä, joiden luo meidän pitää joutua pitäjällä. Minä pelkään sellaisia, joilla on suurtaloja. Heillähän kuuluu olevan kuitenkin kaikki niin hyvin, rahaa kun on, millä ostaa, niin ettei nälkävuosi pysty heihin. Pekan luona on kuitenkin parempi olla. Sisarukset kävelivät ryhmässä Antin ympärillä. Heillä oli niin paljon juttelemista ja tuumaamista. Ja siellä ei kuitenkaan ollut äitiä ollenkaan, siellä Pekan talossa, huomautti Mauno.
  • 59. Ei, sillä silloin hänellä kai olisi ollut siistimpää nurkissaan, — ratkaisi Anna-Liisa. Jos se äiti olisi ollut sellainen kuin meidän äiti, ennenkuin hän kuoli, lisäsi Matleena luoden katseensa ylöspäin. Ei niillä itselläänkään ollut yhtään hauskaa. Meidän pitää kiiruhtaa, että pääsemme joen yli, ennenkuin tulee pimeä, sanoi Antti katsahtaen ympärilleen. Koillisesta rupeaa vinhasti tuulemaan, eikä se ole koskaan mikään hyvä tuuli. Kuinkas pikkutytöt nyt voivat? Antti pysähytti kelkan, kumartui pikkutyttöihin päin ja tukki vällyn lujasti Martta-Eevan ympärille, joka istui Sanna-Kaisan edessä vähän vinossa. Taas lähdettiin matkaan vereksin voimin. Poissa olivat ajatuksista jääkylmä suurtalo ja sen herättämät harmilliset tunteet. Tie oli jotenkin hyvin ajettu. Sitäpaitsi oli peuralauma selvästi äsken kulkenut siitä ja polkenut sen auki. Tuhannet jäljet olivat pitkin matkaa tehneet tien leveäksi ja aukinaiseksi. Punotuista juurista tehty rikkinäinen juustosammio, jollaisia lappalaiset käyttävät valmistaessaan poronmaidosta juustoa, oli keskellä tietä. Matleena otti sen ja asetti tietä osottavan pikkukuusen oksalle. Tule ja anna sen olla, murisi Anna-Liisa. Sen ei ollut siinä hyvä, ja pikkukuusi pyysi minua laittamaan itsensä hienoksi, nauroi Matleena, mutta nyt minä alan väsyä. Äänestä kuului, ettei Matleena ollut hetikään niin hilpeä kuin oli olevinaan. Asetuhan hetkeksi anturoille, niin saat levätä, sanoi Antti. Anna-Liisa ja minä tulemme kyllä teidän kaikkien kolmen
  • 60. kanssa toimeen hyvän matkaa. Pelkään tuolla luoteessa, suurtunturin yläpuolella, asustavaa lumipilveä. — Mutta ei kai kestäne peräti kauvan, ennenkuin pääsemme joelta ja saavutamme kylän, josta Pekka puhui. He kävelivät nopeasti eteenpäin sileää tietä, joka kulki joella jään yli. Pikkutytöt olivat nukkuneet, ainakin he olivat aivan ääneti. Vetäjätkin olivat vaiti. Ilmassa oli ikäänkuin jotain pelottavan uhkaavaa. Tuulenpuuska saavutti heidät pitkään ja valittavasti ulvahtaen: Hui, voisi luulla sutten olevan perässämme, niin ilkeästi ääntelee ilmassa, sanoi Anna-Liisa ja veti ohuen huivin paremmin päähänsä. Sinun on kai sittenkin nyt helpompi kävellä, kun olet saanut jalkoihisi jotain kunnollista? kysyi Antti katsahtaen tosin sangen kömpelöihin, mutta kuitenkin uusiin, mainioihin lapikkaihin. Sepä se vasta oli asia. Voin vaikka hypätä niissä, ja ne pysyvät kumminkin jalassa. Anna-Liisa teki todellakin muutamia ei erikoisen somia hypähdyksiä tietä pitkin. Hän tunsi sillä perinpohjin ärsyttäneensä lumihiutalepilven, joka oli väijynyt lasten tiellä. Sillä yhdessä vilahduksessa ennätti terävästi pieksevä tuisku kietoa heidät ryöppyynsä. Se tunkeutui äkäisesti vinkuen huivien ja saalinriekaleitten sisään. Se heittäytyi tukkuina tien yli, joka muuttui pian epätasaiseksi, kulkien kuin aallonharjoissa. Elleivät pikkukuuset olisi seisoneet tietä viitoittamassa, olisivat lapset äkkiä eksyneet äärettömän aukealla, nyt umpeen pyryttyneellä jokilakeudella. Oli raskasta vetää kelkkaa kasaantuneen lumen halki. Antti huusi Matleenalle, että hän sai nyt kiivetä pois anturoilta. Matleena totteli
  • 61. ja tuli kohta kahlaten sisarusten luo, jotka vuohi keskellänsä muodostivat tiheän ryhmän. Miten kelkka siinä samassa keventyikään! Kovinpa olit raskas. Nyt se on köykäinen kuin tyhjää, sanoi Anna-Liisa nykäisten itselleen nuoran. Hän oli tullut vallan kuin toiselle mielelle saatuaan parempaa jalkoihinsa ja päästyään karvastelevasta kengänhieromasta. Minun mielestäni ei tässä lumessa oikein kykene pääsemään eteenpäin, jupisi Mauno, joka oli juuri keskellä kinosta. Mutta minä kuljen kinosten pohjia, minä, läähätti Pekka-Erkki, siinä kyllä joutuu kulkemaan vähän edestakaisin, mutta minä en totisesti jaksa alinomaa kahlata läpi. Luuletko olevan vielä pitkältä kylään? kysyi Matleena kuiskaten, pujottaen lujasti kätensä Antin toiseen käteen. En, vastasi Antti, joka yritti pitää silmiään auki ja nähdä rajusti tanssivien, piiskaavien lumihiutaleitten läpi. Meidän täytyy pysähtyä ja tukkia ensin lujemmin peitteet pikkutyttöjen ympärille, että saavat lämpöisempää, sitte kuljemme nopeammasti. Antti kääntyi kelkkaa kohden. Hänen mielestään se lumen hohteessa näytti niin merkillisen tyhjältä. Parilla askeleella hän oli sen vieressä. Hän päästi huudon, käheän, kummallisen. Sisarukset eivät varmaan koskaan olleet kuulleet Antin niin huutavan, hänen, joka aina pysyttäytyi hiljaisena ja totisena. Mikä kumma sinua vaivaa, poika? huudahti Anna-Liisa. Martta-Eeva —! Tottahan näette — Sanna-Kaisa, kuuletko sinä!
  • 62. Antti puristi eloa Sanna-Kaisaan, joka nukkui sikeästi. Missä on Martta-Eeva? En minä tiedä, tättä te on yttäpäätä ittunut! Voitteko nyt kulkea yksin eteenpäin, niin minä menen takaisin Martta-Eevaa etsimään, sanoi Antti päättävästi. Kävelkää vain niin nopeasti, että pysytte lämpiminä ja pysykää kuusenviittojen välissä. Niin, teidän pitää tehdä niinkuin minä sanon, toisti Antti arvonsa tuntevasti, mutta kovin murheellisen näköisenä, kun nyt kaiken lisäksi sisarukset pelästyksestä päästivät surkean hätähuudon, suruissaan ja kauhuissaan kun olivat, jäädessään yksin ilman Antin turvallista suojaa. Saattanet toki sinä, Anna-Liisa, pitää suusi kiinni, ja tekin, jotka olette miesväkeä. Minun pitää mennä tietä pitkin takaisin ja etsiä Martta-Eevaa. Hän vierähti varmaan kelkasta heti, kun Matleena oli mennyt kannoilta. Etkö olisi saanut seisoa siinä, että olisit sen nähnyt? Minunkin piti tietysti laiskotella, etten viitsinyt vetää niin monta! Niin, älä nyt sitä sure, nyyhkytti Matleena. Mene ja hae meidän pieni Martta-Eeva. Me kuljemme eteenpäin kuin aikaihmiset. Onhan meillä palanen sianlihaa syödäksemme ja leipää myöskin. Ota sinä lapset huostaasi, Anna-Liisa! Ota osviittaa pienestä juustoseppeleestä kuusenoksalla; kun minä panin sen sinne, olimme kaikki mukana, ja sen vuoksi ei sinun
  • 63. tarvitse mennä sitä kauvemmaksi, huusi Matleena Antin jälkeen, joka nyt puolijuoksua tuulen ja piiskaavan lumen takaa-ajamana lähti kulkemaan umpeentuiskunutta lumikenttää. Kahdeksas luku. MINNE ON MARTTA-EEVA JOUTUNUT? Anna-Liisa koetti saada Sanna-Kaisan vaikenemaan ja rauhoittumaan jokeltavalla puheella ja uudella, lämpimällä maitotilkalla. Pienin, nyt nuorin, tukittiin lujasti kelkkaan kiinni. Matleena asettui täst'edes varmuuden vuoksi taakse työntämään. Hän koetti pitää lumen huikaisemia silmiään auki voidakseen varoa, ettei tämäkin piskuinen vierähtäisi pois ja katoaisi heiltä. Antin kehotuksia vailla he lahnustivat hitaasti ja raskaasti kinosten läpi väsyneinä, pelokkaina, nälkäisinä. He vaelsivat raskaassa surussa Martta-Eevan tähden, joka oli ollut heille suureksi iloksi lystikkäine puheluineen ja hauskoine vehkeineen. He unohtivat aivan, miten väsyttävä hän myöskin oli ollut, kun hän oli huutanut öisin ja tarvinnut hoitoa, vaatetusta ja ruokintaa, kantamista ja askartelemista joka tavalla. Minä ajattelin aina, ettei hän kauvan elä, sanoi Anna-Liisa itkuisella äänellä. Se minunkin mieleeni tuli, kun hän sanoi tahtovansa äitin luo taanaan, lisäsi Matleena surullisen ja huolestuneen näköisenä kuin vanha ihminen.
  • 64. Niin, kunhan ei vain susi olisi häntä ottanut, huomautti Mauno rikkiviisaalla vanhuksen äänellä, sudet ovat vaarallisia näin talvisaikaan. Hallajärvellä niitä on ollut taloissa asti. Poika kulta, ole vaiti, puhui Matleena. Pitääkö tässä kulkea ja ajatella suden repineen pienen Martta-Eevan. Jos ei Antti löydä häntä, on hän lentänyt 'taimaiteen taanaan', ja äiti on ollut hakemassa hänet, vaikka me emme nähneet sitä tässä lumentulvassa. Eipä siitäkään voi olla varma, väitti Pekka-Erkki ajattelevasti sylkäisten eteensä. Virtanen Pihlajavedellä kuuluu pelästyttäneen karhun pesästään, ja nyt se tietysti kiertää ja juoksentelee ympäri seutuja nälissään. Mesikämmen on varmaankin repinyt hänet. Tottakai, matki Matleena Pekka-Erkkiä vinkuvalla äänellä. Ja aina Pihlajavedeltä tänne asti, missä maailma melkein loppuu, on karhu juossut syödäkseen meidän pienen Martta-Eevan. Väinö Paukan isokarju on kai myöskin päässyt ulos ja saanut vihiä hänestä, ja koulunopettajan vanha pässi on hänet vainunnut, saadakseen puskea hänet kuoliaaksi. Matleena rupesi itkemään. Te olette niin ilkeitä keksimään pahaa, kun entuudestaankin jo on huonosti asiat, että — että minä suutun. On kai kauniimpaa ajatella äidin lentäneen tänne noutamaan Martta- Eevaa, joka oli hänelle niin rakas. Jos hän vain olisi jaksanut, olisi hän kyllä ottanut Sanna-Kaisan myöskin. Älä nyt rupea puhumaan sinäkin niinkuin sellainen, joka ei elä kauvan, keskeytti Anna-Liisa sisaren harmin purkauksen. Minun
  • 65. mielestäni meidän ei pidä ajatella mitään, ennenkuin saamme kuulla, miten asia on, kun Antti tulee takaisin. Hän ei löydä meitä koskaan, murisi Mauno. Mutta Antti löysi kuitenkin. Hän tuli kömpien lumessa, kun sisarukset olivat niin väsyneitä, niin menehtyneitä, etteivät enää jaksaneet puhua eivätkä toisilleen vihoitella. He eivät edes jaksaneet pistää kättänsä poveen tunnustellakseen oliko yhtään leivänpalaa jäljellä niistä, joita he olivat sinne panneet. Jos vain Anna-Liisa olisi pysähtynyt tai istuutunut kinokseen lepäämään, olisi koko joukko seurannut hänen esimerkkiään, pikkupojat kaikkein mieluimmin raskaissa, hankalissa vaatteissaan. Helokki etupäässä esti heitä istuutumasta ja siten ijäksi nukkumasta. Jos vain joku lapsista kääntyi siinä tarkoituksessa sivulle, juoksi se tiehensä kova-äänisesti määkien. Ja sitte täytyi heidän kohta mennä perästä, kun he niin pelkäsivät kadottavansa sen. Mutta eivät he kauan jaksaneet siihenkään mukautua. Mauno, joka oli pitkän aikaa horjahdellen kävellyt, kaatui, kiukkuisesti sähisten, kun Anna-Liisa tahtoi auttaa häntä jaloilleen ja saada hänet matkaan. Niinpä oli kuin ihme, että Antti vihdoinkin tuli, sillä hänen kanssaan tuli lapsiin taas elämää ja virkeyttä. Hän tuli kuitenkin ilman pientä Martta-Eevaa —! Aina kuusessa olevaan juustoseppeleeseen saakka oli hän kulkenut, mutta ei ollut nähnyt jälkeäkään heidän pikkutytöstään.
  • 66. Susi kyllä selviää siitä, mitä hän käsiinsä saa, huomautti Mauno epäilevällä syrjämulkauksella Matleenaan, joka loistavin silmin vakuutti, että silloinpa hän kuitenkin oli ollut oikeassa sanoessaan äidin ottaneen Martta-Eevan taivaalliseen Kaanaaseen. Aina susi toki olisi jättänyt jonkin vaaterievun, vakuutti hän innokkaasti. Hoo — hän on kyllä kantanut hänet mukanaan täysissä vaatteissa, väitti Mauno itsepintaisesti. Mitä sinä luulet, Antti? sanoi Matleena ja hiipi pelosta väristen veljen luo. En tiedä. Koko matkan oli vain valkeata, yhteenajautunutta lunta. Matleena, en siedä sitä ajatusta, että susi olisi repinyt pienen Martta-Eevan. On niin raskasta — aivan kuin olisi se minun syyni. Olisit ennemmin iloinen ja tuntisit mielesi keveäksi, sillä äiti on, näetkös, ottanut pikkutytön kokonaan luokseen. Et saa itkeä, Antti. Matleena silitti veikon poskea jäästä kangistuneella lapasellaan, mutta ei se häntä lohduttanut. Suuri poika! Kyyneleet tippuivat sekoittuen kirvelevään lumipyryyn hänen siinä kulkiessaan etukumarassa vetäen nyt lumisohjussakin kuitenkin liian kevyttä kelkkaa. Hän tunsi tuskin helpotusta tienhaaran näkyessä, joka johti joelta maalle. Ja vasta nyt huomasi Antti, että lumimyrsky oli tauonnut ja että taivas illan tullen oli kirkastunut.
  • 67. Yhdeksäs luku. TAIMAINEN TAANA. Jahtimestari Hirvi matkusti kotiin samaa tietä, jota lapset olivat edellisenä päivänä tallustaneet. Hän oli ajanut läheltä ohi heidän pienen, harmaan tupansa Hallatunturilla, sivuuttanut suurmetsän ja ollut kuten lapset pakoitettu rajuilman tähden jäämään ensimäiseen tunturikylään. Hän ei totisesti ajatellut majoittua silmälasimiehen luo, hän, vaan oli asunut majatalossa ja syönyt hyvän aamiaisen hilpeässä seurassa. Ja siten hän oli tullut lähteneeksi myöhään matkalle. Nyt hän ajoi niemen kaltevaa, epätasaista tietä alas, jota lapsetkin vast'ikään olivat menneet, saavuttaakseen joen ja sen poikitse kulkevan tien. Hän istui pienessä kilpa-ajoreessään puettuna sudennahkaturkkiin, karvaiseen lakkiin ja mainioihin peurannahkasaappaisiin, jotka ulottuivat polvien yläpuolelle. Pieksevä pyry ei häntä suuresti vaivannut, varsinkin kun tuuli pian oli muuttuva sivulliseksi. Jahtimestari aikoi oikaista ja valita tien, minkä ainoastaan Leivo, hänen hevosensa, ja hän itse tunsivat, ja joka vei vinosti joen yli harjua kohden isoon kirkonkylään, missä hänen kotinsa oli. Juuri tullessaan erään uloimpana niemellä kasvavan käkkärämännyn kohdalle, missä tie kulki, ja missä hänkin oli pannut merkille oikopolun, säikkyi Leivo ja hyppäsi molemmin etujaloin varovasti jonkin yli, joka makasi keskellä lumen ahtamaa tietä. Sitte ei hevonen hievahtanut paikaltaan, käänsi vain päänsä katsoen isäntään. Jahtimestari hypähti notkeasti kilpa-ajoreestä. Hän
  • 68. kumartui hevosen alle. Taivaan Jumala, mitä tämä oli! Lapsi, yksin tällaisessa autiossa seudussa, pieni raukka kalpein, itkusta kiiltävin poskin, verhottuna köyhiin riepuihin. Jahtimestari seisoi hetken neuvotonna lapsi sylissään. Nukkuiko se, oliko se kuollut? Ei, se eli — se hengitti, rupesi huutamaan. — Äiti — Antti — Elotti —Anna-Aitta. Lapsi nyyhkytti ja huusi kylmästä väristen. Nuori mies seisoi siinä tyhmänä ja neuvottomana. Nainut hän oli ja koti hänellä oli. Mutta hänellä ei ollut pienintäkään tottumusta tai kokemusta pienten lasten käsittelyssä, hänellä kun ei ollut koskaan itsellään lapsia ollut. Leivokin näytti ymmärtävän asian paremmin. Se kaapi etukavioillaan lunta, heitteli päätänsä ja katsoi isäntäänsä. Mikä oli yksinkertaisempaa kuin ottaa mukaan pieni ihmisvarsa, jonka hän oli ollut polkea kuoliaaksi, ja vinhaa vauhtia lähteä sen kera kotiin, missä se saisi lämmintä ja hoitoa. Aivan kuin olisi käsittänyt hevosen ajatuksen kulun, ryhtyi jahtimestari äkkiä toimeen. Hän otti pienen kirkujan ja pujahutti hänet turkkinsa sisäpuolelle. Mutta jotenkin suurella vastenmielisyydellä, sillä jahtimestari oli sangen hieno ja siro mies, joka pelkäsi likaa ja riepuja ja ennenkaikkea kauhistui kirkuvia, niistämättömiä tenavia. Ja tämä oli mitä suurimmassa määrässä kirkuva ja äärimmäisessä niistämisen tarpeessa oleva lapsipoloinen. Kas niin, nyt hänet oli köytetty tiukasti lämpimän turkin sisälle. Lapsukainen vaikeni vähitellen reen keinuessa tiettömän lumen yli ja umpikulkusten kauniisti kaikuvalla äänellä kilistessä. Sillä vaikka
  • 69. olikin raskasta päästä lumen läpi, mennä viiletti Leivo kuitenkin kaikin voimin. Olihan ehdittävä kotiin paleltuneen ihmislapsiraukan kanssa. Jahtimestari, joka ensin oli pitänyt pienokaista suorana edessään kuin hirrenpätkää, kävi niin omituiseksi mieleltään, tuntiessaan pienen, laihan ruumiin värisevän vähitellen heikkenevistä nyyhkytyksistä. Miten hyvältä tuntuisikaan voida lohduttaa ja auttaa sellaista pientä. Hän asetti hänet turkissa parempaan asentoon. Mitähän ruuan puolta sellainen pienokainen tarvitsi? Jumala vahvistakoon minua totisesti, ajatteli hän. Kaikesta ruuasta ja juomasta, jota olen itseeni tänä aamuna ajanut, ei minulla nyt ole pienintä leipäkannikkaakaan jäljellä tällaiselle pikkuruiselle. Saat kiiruhtaa, tyttöseni, kehotti hän hevosta. Leivo päristelihe ja nosti päätään. Eikö hän muka ollut kiirehtinyt rajua lumimyrskyä vastaan, joka repi sekä harjaa että häntää, ja kahlannut lumessa välistä vatsaa myöten. Mutta eipä sillä, saattoi hän kyllä vieläkin lisätä vauhtia, jos niiksi tuli. Niin, hän voisi juosta itsensä pilallekin, juosta, kunnes paikalle kaatuisi, jos isäntä niin tahtoisi! Isäntä, jota hän oli palvellut kymmenen vuotta ja yhdessä hänen kanssaan kulkenut metsät ja tunturit. Tie, joka kulki suuren metsän läpi ja jolle he nyt saapuivat, oli ajettu. Leivo lähti pyyhältämään, niin että kulkusvyö helähteli. Illansuussa oli hän ennättänyt suureen tunturipitäjään, joka levisi tuolla puolen laajan laaksonpohjukan. Sitte riennettiin ylös aikamoista mäkeä. Sinne johti valkorunkoisten koivujen muodostama kuja. He ajoivat sitä pitkin ja pyöräyttivät lopuksi pieneen, vaaleanpunaiseksi maalattuun taloon, jonka parveke ja kuistikko olivat vihreät ja valkoiset. Tuli loisti akkunoista, ja savupatsas kohosi
  • 70. suorana ilmaan, joka nyt oli kuulakkaa ja kirkasta ja johon ruusunpunainen iltarusko ja vähitellen ilmestyvät tähdet valoivat hohtoaan. Tervetuloa kotiin, Artur, huusi nuori rouva parvekkeelta. Hän seisoi siellä suureen villasaaliin kietoutuneena, jonka sisältä hänen hienot kalpeat kasvonsa ja vaalea tukkansa pilkistivät. Kiitos, muijaseni! Pyydä, että Tuovi tulee ottamaan minulta tuomiseni. Tuovi, vanha palvelijatar, joka oli aikoinaan hoitanut jahtimestarin rouvaa, kun tämä oli ollut lapsi, saapui hyväntuulisena alas portaita. Välistä tapahtui nimittäin, että jahtimestarilla oli muassaan jotain harvinaista syötävää tai muuta, karhunpaisti, sudennahka tai tavallisimmin monenlaisia lintuja. Niin että Tuovi oli valmistautunut saamaan suuren sylyksen. Mutta hän vetäytyi pelästyneenä takaisin. No mutta, hyvä jahtimestari! Mitäs me tuollaisella? Menkää sisään, rouva, te vilustutte. Mutta silloin kuului reestä parkaisu, lohduton, hyljätyn pikkulapsen huuto. Nuori rouva heitti pois saalin. Hän juoksi alas portaita muutamin askelin, otti kirkuvan riepukäärön syliinsä ja kantoi sen ylös. Lapsukainen — pieni raukka, mitä he ovat sinulle tehneet? Hiljaa, hiljaa nyt. Pääsemme pian lämpimään ja saamme ruokaa pieneen ruumisparkaan. Kerttu rouva ei pelännyt kirkuvia, niistämättömiä tenavia. Hän oli kyllä tottunut pikkulapsiin vanhempainsa kodissa, missä heitä oli ollut iso sisarusparvi. Hänellä ei itsellään ollut ainoatakaan lasta syväksi, salaiseksi surukseen. Hänen miehensä ei hyväksynyt hänen
  • 71. toivoansa saada ottaa kasvatti. Hän ei nimittäin tahtonut, että he ottaisivat edesvastuulleen toisten lapsia, ja kärsi jo ajatellessaankin häijyjä, tottelemattomia, kirkuvia, likaisia tenavia — muunlaisia lapsia hän ei voinut mielessään kuvitellakaan. Ja nyt hän oli itse kuljettanut pienen lapsen taloon! Illalla syötyään ja levättyään istui jahtimestari ja katseli, miten hänen vaimonsa nopeasti ja taitavasti muutti suuria vaatekappaleita pieniksi, miten hän ihmeellisellä tavalla sai kokoon vaaleansinisen pienen hameen, pienen esiliinan ja parin pieniä housuja. Hän oli niin toimessaan, hänen pikku vaimonsa. Vaaleat hiukset kihartuivat otsalle, ja muuten niin kalpeille poskille oli työ ja työninto nostanut hienon punerruksen. Hän katsahti mieheensä loistavin silmin. Artur, mehän pidämme hänet vastaiseksi? Saat nähdä hänet. Hän makaa Tuovin kamarissa, suuressa vaatekopassa, mihin hänelle on tehty vuode. Hän saanee jäädä, kunnes se ilmestyy, jolla on häneen oikeus. Emmehän voi heittää häntä maantielle. Ihme, etteivät sudet, joita täällä näinä päivinä on liikkunut, siepanneet häntä. Huu, ja sinähän ammuit vasta toissa päivänä kaksi sellaista otusta. Voi, jospa ei kenelläkään olisi oikeutta häneen! Hänen nimensä lienee Marjatta, sillä hän nimittää itseään 'Atta-Eetaksi'. Hän on niin suloinen. Ja tiedätkö, hän risti kätensä kohta, kun oli saanut velliä ja voileipää ja sanoi: 'tiitot tulle', ja hän juttelee niin somasti. Niin, kyllähän sen tietää, mitä tuollainen puolenvuoden vanha tenava tai mitä hän nyt lienee, saattaa jutella.
  • 72. Rakas, hän on paljon yli puolen vuoden, hänellähän on suu täynnä pieniä, valkeita hampaita, ja hän käveleekin niin somasti. Varmaan hänellä on hyvä äiti. Toivon sitä lapsen itsensä vuoksi, jos hän kerran tulee takaisin hänen luokseen. Oi, ei — Artur. Emme me laske häntä pois! Hänellä lienee ainakin sisar tai jokin muu hyvä ystävä, jonka nimi on Voilokki, ja jolla on tapana antaa hänelle maitoa, sillä saadessaan heti tultuaan maitoa, hän huusi yhtä päätä: 'Elotti'. 'Anna-Aitta', sanoo hän myöskin usein. Ymmärrän hyvästi lapsen kieltä ja arvaan hänen tarkoittavan 'valkeata kissaa'. Huomenna koetan saada käsiini valkean kissan. Päästessään sänkyyn, kun olimme saaneet lämpimiksi hänen pienet, paleltuneet jalkaraukkansa, risti hän taas kätensä ja lauloi, tiedätkö, oikein puhtaalla äänellä, niin sievän sävelmän. Sanoineen päivineen? kysyi jahtimestari hiukan ivallisesti, vaikkei hän huomattavasti huvitettuna saattanut olla kuuntelematta vaimonsa selityksiä. Sanoineen, se on tietty, mutta en voi selittää, mitä ne merkinnevät. Lakkaamatta hän lauloi samaa sanaa niin suloisesti, pää kallellaan: 'Taimainen taana'. Voi — 'Kankaiden hanhet'. Sitä laulua äitini lauloi minulle lapsena ollessani, kun minun piti nukkua, laulua 'kankaiden hanhista'. Siitä laulusta uskon oppineeni metsää ja kankaita niin rakastamaan, että minusta tuli metsämies.
  • 73. Eikö ole merkillistä, että tuo pieni, köyhä lapsukainen ylämaan ja katovuoden surkeimmilta seuduilta tulee tänne luoksemme laulamaan laulua, jota kuunnellessasi sinä, alamaan lapsi, pienenä nukuit. Entäs se, että sinä, jonka päähän ei koskaan ole pälkähtänyt selittää lapsenkieltä, nyt heti ymmärsit, mitä hän laulaa. Siinä piilee mielestäni aivan kuin jokin tarkoitus! Niin, on se tosiaankin kummallista, sitä en kiellä, sanoi jahtimestari sangen mielissään siitä, että hänen vaimonsa ymmärsi antaa arvon hänen taidolleen selittää lapsenkieltä. Jos ei kukaan tule takaisin vaatimaan pienokaista, niin kyllä hän minun puolestani saa jäädä. Pahinta on sinun, jonka pitää hoitaa häntä. Minun! Voi, Artur, jos tietäisit, kuinka olen kaivannut pientä lasta! Jahtimestari veti vaimonsa luokseen. Tiedätkö, välistä olen minäkin kaivannut. Hän läksi ulos viheltäen kankaiden hanhia. Sitä laulua hän ei ollut laulanut kuin pienenä poikana. Kymmenes luku. NIIN HIENO TYTTÖNEN. Kahdeksan päivää myöhemmin tulivat lapset hitaasti taivaltaen laahustavin, väsynein askelin mäentörmää ylös vaaleanpunaista taloa kohden, missä jahtimestari asui. Tehtiin siten mutka suurelta
  • 74. maantieltä ja sen varrella sijaitsevista taloista, niin ettei oikeastaan kumpikaan, ei Antti eikä Anna-Liisa, olleet sen puolella. Kenties he eivät saisi vaivainsa palkaksi tuskin leipäpalaakaan. Niin paljon katovuoden väkeä oli läpi talven vaeltanut ennen heitä, minne ikänä he tulivatkin, että saattoi ymmärtää ihmisten väsyvän antamaan. Mutta Matleenan mielestä näytti siltä, kuin mäellä oleva vaaleanpunainen talo olisi ollut puolukoilla ja kermalla sivelty, ja että se ikäänkuin nauroi ja vilkutti heille pikku ikkunoineen, jotka näyttivät katon alta tirkisteleviltä silmiltä. Helokki oli samaa mieltä kuin Matleena. Se kääntyi jyrkästi metsäkumpua kohden johtavalle tielle ja rupesi melkein juoksemaan, niin että lasten enempää miettimättä täytyi seurata sitä. He kävivät, kuten tavallista, hiljaisiksi ja aroiksi saapuessaan taloon. Suuri, harmaa hirvikoira, joka haukkui, ei kuitenkaan säikähdyttänyt heitä. Se näytti pikemmin arvokkaalta ja uljaalta kuin kiukkuiselta. Lapset ohjasivat askeleensa keittiön puolelle ja asettivat kelkan ulkosalle. Tällä kertaa he aikoivat antaa Pekka-Erkin jäädä Helokin luo. Kesken kaiken ja ennenkuin lapset olivat ehtineet sisälle, näkivät he nuoren, hienon rouvan liukuvan kelkalla pihan perukassa sijaitsevaa lyhyttä mäkeä alas. Pieni tyttö oli kelkassa hänen edessään. Pienokainen oli puettu valkoiseen vohlannahkaturkkiin, pieneen, valkoiseen, kudottuun lakkiin, ja jaloissa oli hänellä pienet lapikkaat. Hän nauroi ja hypähteli rouvan polvella huomattavasti riemuissaan kelkalla ajamisesta. Rouva nousi, nosti hänet syliinsä ja suuteli häntä. Rakas pieni Atta-lapsi, nyt käymme sisälle, lapsen pitää syödä ja nukkua päivällistä ja tulla äidin terveeksi, reippaaksi tytöksi.
  • 75. Elotti, Elotti, Antti, Anna-Aitta — Alleena. Pienokainen pyristelihe kiivaasti irroittuakseen käsivarsista, jotka hellästi ympäröivät häntä. Kerttu rouva kääntyi nopeasti. Hän päästi lapsen, joka innokkaasti juoksi hänen tyköään, ja antoi käsivartensa vaipua, seisoen hiljaa paikallansa surun ja yksinäisyyden valtaamana. Lapset olivat kuin kivettyneitä. He seisoivat hiiskahtamatta, liikkumatonna. Mutta Helokki oli kohta asian perillä. Se päästi määkinän ja juoksi Martta- Eevan luo. Mitäpä hän siitä huoli, että pienokainen oli, lapikkaita lukuunottamatta, hieno kuin prinsessa. Sehän oli kuitenkin sama pieni ihmisvohla, jolle hän oli antanut maitoa, ja jota hän oli turkillaan lämmittänyt. Elotti! Martta-Eeva kiersi käsivartensa vuohen pään ympärille, joka taipui häneen päin. Hän ojensi käsivartensa. Puttaa! Antti itä! Antti ota Atta-Eeta! Ja Antti otti syliin pikku siskon. Hän silitti hänen poskiaan, hänen käsiään. Pikku tyttönen, — meidän pikku tyttömme! Sinä rakas Martta-Eeva. Niin raskasta on meidän ollut ilman sinua. Martta-Eeva piti käsivarsiaan hänen kaulassaan, niinkuin hän ei koskaan olisi tahtonut päästää häntä. Mutta sitte tahtoivat toiset sisarukset saada osansa, pieni Sanna-Kaisa ja kaikki muut olivat muodostaneet piirin heidän ympärilleen ja nykivät jälleen löydettyä käsivarsista ja sääristä saadakseen hekin hänet hyväilläkseen ja taputellakseen. Martta-Eeva, heidän korea, hupainen pikku lapsensa, jota he olivat niin suuresti ikävöineet! — Sama pikkutyttö, vaikka hän nyt oli
  • 76. hienoissa herrasvaatteissa. He eivät laskeneet häntä, vaan tullessaan keittiön kautta sisään kerjäämään oli heidän parvessaan pieni, valkoisiin puettu, hyvin hoidettu lapsi. Yhdestoista luku. MOLEMMAT PIKKUTYTÖT. Kun Hallatunturin lapset jälleen vaelsivat jahtimestarin talosta, oli heitä enää vain viisi. Sanna-Kaisa oli saanut jäädä pikku siskon luo. Ja niin olivat pikkutytöt taasen yhdessä. Jahtimestari itse oli niin tahtonut. Järjestyksen ihmisenä hän huomasi ja hämmästyikin äärettömästi ja ihmetteli, kun uusi, pieni ryppymekko, joka hänen mielestään saattoi tuskin ymmärtää viedä ruokaa suuhunsa, tuli hänen huoneeseensa kiittämään ruuasta ja heti huomasi hänen paperiveitsensä pöydän alla. Pöydän alla on veitsi, piipitti hän hienolla äänellä ryömien mainittua esinettä hakemaan. Ja totisesti, paperiveitsi, jota hän, jahtimestari, niin varoi ja jota hän turhaan oli etsinyt, oli hänen kirjoituspöytänsä alla melkein piilossa, poronnahan peitossa. Tahtoisitko antaa sen minulle, sanoi hän ojentaen kätensä. Sanna-Kaisa astui heti esiin jättäen veitsen. Jahtimestari, joka tiesi, miten vaikeata oli saada totutetuksi koiria noutamaan esineitä, miltei nolostui. Hän oli luullut vielä vaikeammaksi saada lasta tottelemaan.
  • 77. Anna-Aitta tulee, uuti nutte, laulaa, toutaa — taimaan taana, uuti nutte. Martta-Eeva, joka oli jo aivan kotiutunut jahtimestarin kauniissa, hauskassa huoneessa, tuli sisään tallustaen ja veti nyt Sanna-Kaisan mukanaan. Hän tahtoi näyttää hänelle uuden nukkensa, sellaisen oikean, jolla oli kirkkaat silmät hienossa posliinipäässä, ja hän tahtoi, että he laulaisivat ja tuutisivat hänet uneen, kuten heidän oli ollut tapana tehdä entisille nukeilleen. Pienokaiset valmistivat nukelle vuoteen sänkykamariin. Siellä kasvattivanhempien luona oli Martta-Eevalla nyttemmin oma, hieno sijansa pienessä sirossa sängyssä. Sanna-Kaisa laski myöskin oman nukkensa, riepuihin kiedotun halon, konelaatikkoon —. Sitte pikkutytöt lauloivat suloisesti ja hartaasti laulunsa taivaallisesta Kaanaasta molemmille unisille nukeille keikuttaen laatikkoa välillänsä. Kerttu, kasvattiäiti, juoksi hakemaan miestään. Hänen täytyi kuulla ja nähdä heidät yhdessä, nähdä ja verrata jo punaposkista, vapaasti katselevaa pientä löytölasta sievissä, oivallisissa vaatteissaan, toiseen, pieneen, kalpeaan raukkaan kärsivine katseineen ja ohkaisine, lopen kuluneine repaleilleen. Kerttu tiesi hyvin, minkätähden hän halusi esittää tämän kuvan miehelleen. Molemmat puolisot seisoivat toisiinsa nojautuneina, kuunnellen lasten laulua. Artur sinä. — He laulavat 'Taivaan Kaanaasta'. Kuule tätä pientä, uutta tulokasta! Eikä 'Kankaiden hanhista', lisäsi hän arasti. Ei kai tuo pieni Jumalan enkeli ole mielestäsi sinua narrannut? Ei, totisesti, ei. Sanon sinulle, etten nyt ensinkään tahtoisi olla ilman häntä. Talossa tulisi taas niin tyhjää ja hiljaista.
  • 78. Muistatko sananlaskua: 'Pata, joka keittää yhdelle, keittää yhtä hyvin kahdelle'. Sanotko niin —! Jahtimestari katseli miettivän näköisenä lattialla istuvia pienoisia, jotka yhä lauloivat ja keikuttivat konelaatikkoa välillään. Toinenhan heistä hänen täytyi pitää ja hän tahtoikin sen tehdä. Mutta toisen — tuon kalpean pienen olennon, ohuine poskilleen ja tummine, kärsivine silmineen — niin, hänen täytyi taas maantielle. Eikä kellään heistä ollut äitiä eikä isää, sen oli hänen vaimonsa kertonut. No niin, anna sitte Jumalan nimessä padan kiehua kahdelle, sanoi hän viimein. Lapset lauloivat laulamistaan kasvattivanhempien totisina, kirkkain kasvoin mennessä suurempien lasten luo, jotka istuivat keittiössä puhellen Tuovin kanssa. He eivät tahtoneet ottaa pienoisia ilman suurempien myöntymystä. Ja voihan käsittää, että pikkutyttöjen oli hyvä jäädä pieneen taloon, missä itse ikkunatkin hymyilivät ja vilkkuivat katon harjan alla, ja missä seinätkin olivat kuin puoloilla ja kermalla siveltyjä. Kahdestoista luku. TYÖ-ANSIOITA JA RAHAKYSYMYKSIÄ. Kun jäljelläolevat lapset nyt jatkoivat matkaansa, eivät heidän ajatuksensa enää olleet niin raskaita. Heillä oli niin paljon ihmeellistä puhuttavana. Ensiksikin koreasta rouvasta, jonka silmät olivat niin
  • 79. lempeät. Lakanoista pitseineen ja punaisista peitteistä pikkutyttöjen vuoteissa ja hienosta, hyvästä ruuasta, jota pienokaisilla nyt alati olisi. Ja nähkääs, he ovat tulleet oikeitten ihmisten luo, sellaisten, joihin äitikin olisi suostunut, sanoi Antti totisesti. Rouva istui eilen illalla korisängyn ääressä ja antoi pikkutyttöjen lukea pienen rukouksensa, ja sitte hän sanoi, että he rukoilisivat Jumalaa suojelemaan sisaruksia, jotka kulkevat ulkona maailmalla, ja antamaan meidän kaikkien tulla kilteiksi, hyviksi ihmisiksi. Siitä minä pidin, siksi he saivat jäädä sinne. Olisi kai sinun pitänyt antaa heidän jäädä suurtaloonkin, jos he olisivat tahtoneet pitää pikkutytöt, vaikka väki olikin sekä nyrpeää että häijyä, sanoi Anna-Liisa vähän pisteliäästi. Ei koskaan, puuttui Antti kiivaasti puheeseen, tiedä se. — Sinnekö, missä isäntä niin ankarasti kirosi! Mikä onnettomuus hyvänsä voi kohdata sellaista taloa; ja siitä saisivat pikkutytötkin kärsiä. Niin, lisäsi Mauno, ja pihalla huusivat rengit, joiden piti asettaa hevoset takarekien eteen, alituisesti 'tuhat perkelettä'. Hui, sehän on aivan hirvittävää, sanoi Matleena kauhistuen. Näin hän sanoi, jatkoi Mauno ikäänkuin hyvillänsä saadessaan sitä hirvittävää toistaa: Anna tänne se perkeleen kirves, että saan lyödä naulapahuksen kirottuun takarekeen. Vaiti poika! Oletko hullu, kun suorastaan vedät onnettomuutta ylitsemme puhumalla niin kauheita sanoja. Äiti, kun aina niin pelkäsi
  • 80. kirosanoja, sanoi Antti pelästyneenä ja pahoillaan. Eikä teidän toki tarvitse ajatella, että olisin jättänyt pikkutytöt sellaiseen taloon, vaikka he olisivatkin saaneet nisujauhopannukakkua ja sianlihaa ja vehnäskahvia joka ikinen päivä. Niin, pikkutytöt olisivat kai oppineet kiroamaan sellaisessa talossa hekin, epäili Pekka-Erkki. Mutta niillä oli siellä neljä hevosta, ja seinällä pyssy, ja isännällä oli tuppipuukko, joka oli oikein kaunis, niin että kyllä pikkutytöt olisivat tavallansa voineet sielläkin hyvin, arveli Mauno. Nyt saatte nähdä tuppipuukon, jonka sain jahtimestarilta, keskeytti Antti. Hän otti povestaan tuppeen pistetyn puukon, jossa oli musta kiiltävä varsi ja nahkatuppi, ja jonka terä oli ohutkärkinen ja välkkyvän terävä. Ei mutta, poika! Mauno pysähtyi keskelle tietä kuin kivettyneenä. Sillä kai on tuhat kruunua, joka hennoo antaa pois tuollaisen. Mistä se tuli, että hän sen teki? Minun piti auttaa Tuovia päreitä pilkkomaan, ja minulla oli vain vanha puukkoni. En tiedä, liekö hän sanonut jotakin jahtimestarille, mutta kun olin hänen luonaan sisällä kiittämässä meidän edestämme, antoi hän minulle puukon. Ja sitte hän sanoi, että kunnon poika, joka osaa hyvin käyttää puukkoansa, aina voi tulla toimeen maailmassa ja kunnialla päästä eteenpäin. Sellainen puhe kuuluu korealta, sanoi Matleena uneksien. Se rouva, joka oli niin kovasti näppärä, antoi minulle niin hienoa lankaa.
  • 81. Tässä saatte nähdä. — Matleena otti esiin paperitötterön ympärilleen solmitusta saalista. He pysähyttivät kelkan. He olivat nyt keskellä metsikköä poissa ihmisten silmistä. Matleena istui kelkkaan. Kas tässä — punaista lankaa ruusuihin, ja vihreää lehtiin, ja ruskeaa varsiin. Mutta mihin — mihin hyvänen aika ne ovat aiotut? kysyi Anna- Liisa yhtä hämmästyneen näköisenä kuin toisetkin sisarukset, jotka äärimmäisen kummastuksen valtaamina ottivat Matleenan koreuden katseltavakseen. Joukossa oli myöskin harmaa lankakerä, johon oli kiinnitetty luinen virkkineula, sukkavarraskerta ja kiiltävä parsinneula. Tuo taitava rouva sanoi minulle näin: 'Osaatko kutoa?' sanoi hän. Hertti, tottahan sitä osannet, suhahti Anna-Liisa. Älä nyt — niinhän minä sanoinkin. — Voithan antaa minun puhua loppuun! 'Kyllä', sanoin minä. No, mitä hän sitten sanoi? kysyi Mauno innokkaasti. 'Tässä saat nähdä', sanoi hän. Mitä sitte sait nähdä? intoili Pekka-Erkki, joka kuljetti kättänsä korean langan yli kuin olisi tahtonut hyväillä sitä. Surkeus suuri, kuinka te kyselette ja pidätte meteliä, niin että minä syön, mitä minun piti sanoa, enkä enää muista sitä! Sinun piti saada nähdä jotakin, auttoi Antti häntä tolalle.
  • 82. Niin se oli, mutta vaiti nyt. Hän näytti minulle parin lapasia, nähkääs, niin hienoja lapasia, ettette ole sellaisia nähneet. Ne kai maksavat paljon rahaa, se on tietty, sanoi Mauno ajattelevaisesti. Niin kyllä, näetkös, mutta ei sille, joka voi valmistaa sellaisia — sillä silloin maksaa ainoastaan lanka. Lanka, niin, mutta ei se maksane vähän sekään, tuumasi Anna- Liisa. Te sitte vasta olette kiusallisia keksimään ikävyyksiä, niin että minä töin tuskin haluan puhua loppuun, napisi Matleena. Hän otti kuitenkin armollisesti esille puoleksi kudotun lapasen, missä valkoinen villalanka vielä oli kiinni. Se oli valmistettu koukkuamalla, millä tavalla Norrlannin naiset ennen pienellä luukoukulla virkkasivat erinomaisen lujia lapasia. Ja lapasen puoliskolle oli villalangalla neulottu punaisia ruusuja, vihreitä lehtiä ja ruskeita varsia. Annas olla, joko nyt käsitätte, missä ruusujen ja lehtien paikka on? Matleena salli pienen lapaspuolikkaan kulkea sisarusten kesken. Niin, mutta kuka sen nyt tekee! Et sinä nyt ainakaan voi saada aikaan sellaista, joka on niin hienoa ja mutkikasta, sanoi Mauno ylimielisesti ja musertavalla varmuudella. Ei, se on selvää, kinasteli Matleena. Sinä kai luulet itse siihen paremmin pystyväsi — sinä, joka parsii sukkia niinkuin kurotaan
  • 83. kiinni jauhopussin suu, vedät vain reijän kokoon — vaikka se olisi kuinka suuri. Matleena, varo itseäsi, ettet tule suulaaksi, muistutti Antti. Eikä ollenkaan ole somaa, kun naisväki käy sellaiseksi. Sittepähän mies voi olla vaiti, kun ei tiedä mitään siitä, josta pitää ääntä. No, senhäntähden kysyy, kun ei mitään tiedä, jatkoi Antti sävyisästi. En minäkään tiedä, miten sinä menettelet noiden ruusujen suhteen, tai miten saat aikaa sellaiseen työhön. Niin, mutta minä tiedän. Kun sinä eilen olit ulkona ja kannoit heille vettä ja loit lunta, olin minä sisällä rouvan luona, ja hän auttoi minua laittamaan tämän nutun. Ja minä sain neuloa tämän esiliinankin itselleni. Minäkin sain ommella itselleni sellaisen, sanoi Anna-Liisa ylpeästi. Ja kun se oli tehty, näytti hän minulle, miten minun pitäisi koukuta. — Katsokaas näin! Mutta se on tietysti peräti mutkallista. Pakkasen punertamin, jäykin sormin, nenä vuotavana ja suu juhlallisesti kokoonpuristettuna näytti Matleena sisarusten silmissä ihmeteltävää koukkuamistaitoaan. Ja sitte, nähkääs, tulee kaikista merkillisin. Hän pujotti tärkeän näköisenä punaisen langan parsinneulan silmään. Sitte katsokaas — tulee kaikista kummallisin. — Että minä
  • 84. osaan neuloa — näin — koreaa. Hän neuloi vain muutamia pisteitä, mutta sekin jo herätti sisaruksissa tarpeellista kunnioitusta. Matleena hypähti pystyyn, pisti langan talteen ja otti oikean ajoluiun, sillä eipä luminen maa monen asteen pakkasessa ollut juuri sopivin neulomakoulun paikka. Tästä lähtien, nähkääs, koukkuan lapasia ja neulon niihin ruusuja ja — myyn niitä, kuulettekos, — ja saan rahaa ja ostan meille pienen tuvan, joka näyttää puolukoilta ja kermalta, ja jossa on nauravat ikkunat. Pikkutytöt ja kaikki tyyni teemme sitte lapasia. Oikeita oman maan lapasia —, sillä rouva sanoi, että tekisimme kaikki aivan kuin ajatellen oman maan nimen tulevan työhön mukaan; kaikki tehtävät ovat suoritettavat tietysti sillä tavalla, ettei isänmaa joudu häpeään. Kun vain tulee kevät, rupean kulkiessani kutomaan, sillä hän sanoi, että näin on vaimoväki täällä ennenkin tehnyt. Kudon pikkusukkia teille päivin ja sitte illoin, kun istumme jossakin koivuhaassa, koukkuan ja neulon ruusuja, joista tulee niin koreita kuin orjanruusut. Minä en suinkaan aio ryhtyä lapasia koukkuamaan, sanoi Mauno ojentautuen ja kääntäen ranteista liian pitkiä, riippuvia nutunhihojaan. Ei, minä puolestani lähden Amerikkaan ja kaivan niin paljon kultaa, että voin ostaa koko Hallatunturin pitäjän ja kirkon, jos tahdon, ja täyttää sen karpaloilla ja tuoreilla juustoilla ja luhdikoilla ja sianlihalla ja — Mauno kellahti sivuun. Kohti kurkkua huutaen ja pelästyneenä hän koetteli kädellä poskeaan. Siinä poltti korvapuusti. Antti, joka ei ollut kurittanut lapsia äidin eläessä, ja joka tavallisesti oli ihmeellisen kärsivällinen
  • 85. heidän suhteensa, vihastui tulisesti. Mauno sai korvapuustin, ja Antti rupesi häntä puristelemaan, juuri kuin hän olisi ollut perunasäkki, johon oli saatava enemmän tilaa. Poika, ettet häpeä! — Pidätkö vierasta maata parempana omaa —! Lähteä sinne kullan hakuun! — niinkuin meidän setä, joka on turmellut siellä itsensä. Ja vielä sekin, että kullalla ostaisit kirkon siksi vain, että pitäisit koreaa kirkkoa, missä Jumalasta saarnataan, aittana —. Sinulla on, Mauno, ilkeä mieli, ja tuollaista puhetta en kärsi kuunnella. Lapset kävelivät tavallista kulkijahölkkää, sangen noloina Antin odottamattomasta kiukunpuuskauksesta. Mauno pirottaen ja itkua tuhertaen. Miehen on paljon parempi tehdä lapasia kunnialla kuin nostaa säkittäin kultaa ja käyttää sitä siihen, mikä on pahaa — muista se, Mauno, jatkoi Antti vielä aivan hengästyneenä harmista. Hän kahlasi metsikköön kinoksen läpi ja leikkasi terävällä puukolla kuusenlatvan, jonka oksat olivat niin tasaisena kehänä rungossa kiinni, että se hyvin sopi männäksi. Hän koetti jälleen leppyä. Kun eivät pikkutytöt nyt istu kelkassa, sanoi hän, niin olen ajatellut kuljettaa siinä työaineksia askartaakseni iltaisin, kun tulemme johonkin taloon, missä on tuli takassa, tai jonnekin leipomatupaan tai renkikamariin. Aiotko tehdä mäntiä ja pesimiä myytäväksi? kysyi Anna-Liisa jonkinlaisella kunnioituksella mahtavalta veljeltään. Niitä olen enimmäkseen ajatellut. Puulusikoita myöskin. Simo- Paavalin vaari oli mainio lusikoita tekemään, mutta eihän minulla
  • 86. koskaan ole ollut puukkoa, että olisin voinut veistää niiden mukaan. Ne minä sinulle maalaan, huusi Matleena metsikköön päin Antille. Niin koreita, pieniä, sinisiä ruusuja ja vuohensilmiä. Valmistan väriä, niinkuin äitikin, lehdistä, kukkasista ja juurista. Saanko auttaa sinua lusikoita tekemään, kun tulen suureksi? mutisi Mauno, tullessaan Antin läheisyyteen tiellä. Saat kyllä, poika. Kas tässä vanha puukkoni, sillä voit, vaikka olet pieni, alkaa tehdä aineksia. Voimmehan myydä lusikat, Antti, ja saada rahaa. Mutta en minä sentään ostakaan kirkkoa, sillä pappi ei voi siellä silloin lukea. Ei, emmekä me voi istua siellä ja kuunnella häntä ja veisata ja lukea, että meistä tulisi hyviä ihmisiä, niinkuin äiti toivoi. Kolmastoista luku. VAINAJAN SIJAAN. Kun lapset muutamia päiviä myöhemmin ehtivät niin kauvas, että pääsivät pahimmasta tunturiseudusta, tulivat he eräänä iltana taloon, missä sairaus ja surut olivat vieraina. Suureen, rikkaaseen talonpoikaistaloon. Vanhin tyttö oli siellä äsken kuollut ainoastaan 10 vuoden vanhana. Ja nyt makasi pieni poju, ainoa poika, seitsenvuotias, sairaana samassa taudissa, johon sisar oli kuollut. Vaimo, uljas, kaunis nainen, seisoi takan ääressä ja vispilöitsi
  • 87. Welcome to our website – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com