PowerShell in Practice
Richard Siddaway
  • June 2010
  • ISBN 9781935182009
  • 584 pages
  • printed in black & white

A definitive source.

Wolfgang Blass, Microsoft Germany

PowerShell in Practice covers 205 individually tested and ready-to-use techniques, each explained in an easy problem/solution/discussion format. The book has three parts. The first is a quick overview of PowerShell. The second, Working with People, addresses user accounts, mailboxes, and desktop configuration. The third, Working with Servers, covers techniques for DNS, Active Directory, Exchange, IIS, and much more. Along the way, you'll pick up a wealth of ideas from the book's examples: 1-line scripts to full-blown Windows programs.

Table of Contents detailed table of contents

preface

acknowledgments

about this book

about the author

about the cover illustration

Part 1 Getting started with PowerShell

1. PowerShell fundamentals

1.1. What’s PowerShell?

1.2. Why PowerShell?

1.3. Major features

1.4. PowerShell v2

1.5. Summary

2. Learning PowerShell

2.1. Open the book—learn by doing

2.2. Installation and configuration

2.3. Your four best friends

2.4. Language features

2.5. Scripts

2.6. Summary

3. PowerShell toolkit

3.1. Eureka 2

3.2. Using .NET

3.3. Using COM

3.4. Using ADSI

3.5. Using WMI

3.6. Summary

4. Automating administration

4.1. Benefits of automation

4.2. Administration styles

4.3. Development for administrators

4.4. Best practice

4.5. Automation toolkit

4.6. Securing PowerShell

4.7. Summary

Part 2 Working with people

5. User accounts

5.1. Automating user account management

5.2. Local users and groups

Technique 1 User creation

Technique 2 Group creation

Technique 3 Group membership

5.3. Active Directory users

Technique 4 User creation

Technique 5 User creation (bulk)

Technique 6 User modification

Technique 7 Finding users

Technique 8 Enabling and disabling accounts

Technique 9 Moving accounts

Technique 10 Last logon time

Technique 11 Password expiry

Technique 12 Account expiry

5.4. Active Directory groups

Technique 13 Group creation

Technique 14 Changing membership

Technique 15 Changing scope

Technique 16 Finding group members

Technique 17 Finding a user’s group membership

5.5. Summary

6. Mailboxes

6.1. Automating mailbox management

Technique 18 Create a mailbox

6.2. Enabling mail

Technique 19 Mailboxes

Technique 20 Mail-enabled

Technique 21 Contact

6.3. Modifying mailboxes

Technique 22 Mailbox size limits

Technique 23 Enabling IMAP

Technique 24 Enabling POP

Technique 25 Enabling OWA

Technique 26 Adding an email address

Technique 27 Hiding an address from the address list

Technique 28 Moving a mailbox

Technique 29 Disabling mail

Technique 30 Reconnecting a mailbox

6.4. Distribution groups

Technique 31 Creating a distribution group

Technique 32 Mail-enabling a group

Technique 33 Dynamic distribution group

Technique 34 View distribution group membership

Technique 35 Modify distribution group membership

6.5. Mailbox statistics

Technique 36 Determining the largest mailboxes

Technique 37 Reporting on mailbox sizes

6.6. Deleting mailboxes

Technique 38 Deleting a mailbox

Technique 39 Purging a mailbox

6.7. Summary

7. Desktop

7.1. Automating desktop configuration

7.2. Machine configuration

Technique 40 System configuration

Technique 41 Discovering the operating system

Technique 42 Discovering service packs on the OS

Technique 43 Hotfixes

Technique 44 Listing installed software

Technique 45 Monitoring free disk space

Technique 46 Renaming a computer

Technique 47 Restarting a computer

7.3. User features

Technique 48 Minimizing windows

Technique 49 Desktop contents

Technique 50 Adding a file to the desktop

Technique 51 Listing cookies

Technique 52 Viewing recycle bin contents

Technique 53 Emptying the recycle bin

Technique 54 Sending a printer test page

Technique 55 Printer drivers

7.4. Office applications

Technique 56 Creating an Excel spreadsheet

Technique 57 Adding data to a spreadsheet

Technique 58 Opening a CSV file in Excel

Technique 59 Creating and writing to a Word document

Technique 60 Creating a configuration report

7.5. Summary

Part 3 Working with servers

8. Windows servers

8.1. Automating server administration

8.2. Services and processes

Technique 61 Service health check

Technique 62 Managing services

Technique 63 Managing processes

Technique 64 Launching processes

8.3. Filesystem

Technique 65 Creating folders

Technique 66 Creating files

Technique 67 Reading files

Technique 68 Searching files

Technique 69 Searching for files

8.4. Registry

Technique 70 Accessing the registry

Technique 71 Reading registry data

Technique 72 Creating registry entries

Technique 73 Managing registry data

8.5. Event logs

Technique 74 Reading event logs

Technique 75 Exporting logs

Technique 76 Creating an event log

Technique 77 Creating events

Technique 78 Managing event logs

8.6. Summary

9. DNS

9.1. Automating DNS administration

9.2. DNS server

Technique 79 Enable remote administration

Technique 80 View server configuration

Technique 81 Configuring round robin

Technique 82 Configuring conditional forwarding

Technique 83 Clearing the server cache

9.3. DNS zones

Technique 84 Creating a DNS zone

Technique 85 Viewing zone configuration

Technique 86 Viewing zone contents

Technique 87 Deleting a DNS zone

9.4. DNS records

Technique 88 Creating DNS A records

Technique 89 Creating DNS AAAA records

Technique 90 Creating DNS MX records

Technique 91 Creating DNS CNAME records

Technique 92 Creating DNS PTR records

Technique 93 Querying DNS records

Technique 94 Deleting DNS records

9.5. Client settings

Technique 95 IP address configuration

Technique 96 Setting an IP address

Technique 97 Testing IP connectivity

9.6. Summary

10. Active Directory structure

10.1. Automating Active Directory administration

10.2. Schema

Technique 98 Schema version

Technique 99 Forest and domain level

Technique 100 Default display name

10.3. Organizational units

Technique 101 Creating an OU

Technique 102 Bulk creation and nesting

Technique 103 Listing OUs in a domain

Technique 104 Discovering child objects

Technique 105 Moving an OU

Technique 106 Deleting an OU

10.4. Group Policies

Technique 107 Creating a GPO

Technique 108 Linking a GPO

Technique 109 Listing GPOs

Technique 110 Listing GPO contents

Technique 111 GPO backup

10.5. Protection and recovery

Technique 112 Protection from accidental deletion

Technique 113 Object recovery

10.6. Summary

11. Active Directory topology

11.1. Automating AD topology administration

11.2. Domain controllers

Technique 114 Discovering domain controllers

Technique 115 Discovering global catalog servers

Technique 116 Promoting to a global catalog server

Technique 117 Discovering FSMO roles

Technique 118 Transferring FSMO roles

Technique 119 Monitor replication

Technique 120 Triggering replication

11.3. Sites

Technique 121 Listing sites

Technique 122 Creating a site

Technique 123 Modifying a site

Technique 124 Deleting a site

11.4. Subnets

Technique 125 Listing subnets

Technique 126 Creating a subnet

Technique 127 Modifying a subnet

Technique 128 Deleting a subnet

Technique 132 Determining replication schedules

Technique 133 Setting replication schedules

11.6. Summary

12. Exchange Server 2007 and 2010

12.1. Automating Exchange Server 2007 administration

Technique 134 Exchange Server health

Technique 135 Exchange organization

Technique 136 Exchange Servers

12.2. Data stores

Technique 137 Creating storage groups

Technique 138 Creating databases

Technique 139 Mailbox distribution

Technique 140 Distributing mailboxes

Technique 141 Moving a database

Technique 142 Removing a database

12.3. Policies

Technique 143 Email address

Technique 144 Transport rules

Technique 145 Attachments

Technique 146 Journal rules

12.4. Certificates

Technique 147 Viewing certificates

Technique 148 Self-signed certificates

Technique 149 Third-party certificates

12.5. Resource mailboxes

Technique 150 Creating a resource mailbox

Technique 151 Viewing resource mailboxes

Technique 152 Calendar settings

12.6. Exchange Server 2010

Technique 153 Remote capabilities

12.7. Summary

13. IIS 7 and XML

13.1. Automating IIS 7 administration

Technique 154 PowerShell remoting

13.2. Websites and application pools

Technique 155 Viewing websites

Technique 156 Controlling websites

Technique 157 Creating an application pool

Technique 158 Controlling an application pool

Technique 159 Modifying website configuration

Technique 160 Removing a website and application pool

Technique 161 Configuring a new website on multiple machines

13.3. Web applications and virtual directories

Technique 162 Creating a web application

Technique 163 Add a virtual directory

Technique 164 Removing virtual directories and web applications

13.4. XML and configuration files

Technique 165 Persisting objects

Technique 166 Reading XML

Technique 167 Backing up the IIS configuration

Technique 168 Reading web configuration files

Technique 169 Modifying web configuration files

Technique 170 Creating HTML

13.5. Summary

14. SQL Server

14.1. Automating SQL Server administration

14.2. Server administration

Technique 171 Checking service health

Technique 172 Viewing the server version

Technique 173 Viewing server configuration

Technique 174 Modifying the server configuration

Technique 175 Network configuration

Technique 176 Viewing performance counters

14.3. Database administration

Technique 177 Finding databases

Technique 178 Viewing space used

Technique 179 Creating a job

14.4. Configuration database

Technique 180 Creating a database

Technique 181 Creating a table

Technique 182 Modifying a table

Technique 183 Adding keys

Technique 184 Populating a table

Technique 185 Reading data

Technique 186 Modifying data

Technique 187 Deleting data

Technique 188 Backing up a database

14.5. Summary

15. PowerShell innovations

15.1. PowerShell jobs

Technique 189 Creating a job

Technique 190 Viewing jobs

Technique 191 Viewing data

Technique 192 Deleting a job

15.2. Windows 2008 R2

Technique 193 Modules

Technique 194 Server Manager

Technique 195 Troubleshooting

Technique 196 Best practice

Technique 197 Active Directory provider

Technique 198 Creating an AD drive

15.3. Virtualization

Technique 199 Discovering Hyper-V functions

Technique 200 Virtual machine status

Technique 201 VM uptime

Technique 202 Checking disk status

Technique 203 Checking disk usage

Technique 204 Compacting disks

15.4. PowerShell in the cloud

15.5. Summary

afterword PowerShell is for you

Appendix A: PowerShell reference

Appendix B: Modules and advanced functions

Appendix C: PowerShell events

Appendix D: Reference data

Technique 205 Understanding the user account control values

index

About the Technology

PowerShell is a powerful scripting language that lets you automate Windows processes you now manage by hand. It will make you a better administrator.

What's inside

  • Basics of PowerShell for sysadmins
  • Remotely configuring desktops and Office apps
  • 205 practical techniques

About the reader

This book requires no prior experience with PowerShell.

About the author

Richard Siddaway is an IT Architect with 20 years experience as a server administrator, support engineer, DBA, and architect. He is a PowerShell MVP and founded the UK PowerShell User Group.


Buy
  • combo $49.99 pBook + eBook
  • eBook $39.99 pdf + ePub + kindle

FREE domestic shipping on three or more pBooks

A must read!

Peter Johnson, Unisys Corp.

A new perspective on PowerShell!

Andrew Tearle, Thoughtware N.Z.

Real-world examples in a language you can understand.

Marco Shaw, Microsoft MVP