1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Windows PowerShell Programming P1 ppt

30 581 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 30
Dung lượng 689,16 KB

Nội dung

Kumaravel ffirs.tex V1 - 01/09/2008 8:43pm Page iii Professional Windows PowerShellProgramming Snap-ins, Cmdlets, Hosts, and Providers Arul Kumaravel Jon White Michael Naixin Li Scott Happell Guohui Xie Krishna C. Vutukuri Wiley Publishing, Inc. Kumaravel ffirs.tex V1 - 01/09/2008 8:43pm Page ii Kumaravel ffirs.tex V1 - 01/09/2008 8:43pm Page i Professional Windows PowerShellProgramming Preface xvii Introduction xix Chapter 1: Introduction to PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Chapter 2: Extending Windows PowerShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Chapter 3: Understanding the Extended Type System . . . . . . . . . . . . . . . . . . . . . . 29 Chapter 4: Developing Cmdlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 Chapter 5: Providers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 Chapter 6: Hosting the PowerShell Engine in Applications . . . . . . . . . . . . . . . . . 165 Chapter 7: Hosts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Chapter 8: Formatting&Output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233 Appendix A: Cmdlet Verb Naming Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 257 Appendix B: Cmdlet Parameter Naming Guidelines . . . . . . . . . . . . . . . . . . . . . . . . 263 Appendix C: Metadata . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 271 Appendix D: Provider Base Classes and Overrides/Interfaces . . . . . . . . . . . . 283 Appendix E: Core Cmdlets for Provider Interaction . . . . . . . . . . . . . . . . . . . . . . . . . 303 Index 307 Kumaravel ffirs.tex V1 - 01/09/2008 8:43pm Page ii Kumaravel ffirs.tex V1 - 01/09/2008 8:43pm Page iii Professional Windows PowerShellProgramming Snap-ins, Cmdlets, Hosts, and Providers Arul Kumaravel Jon White Michael Naixin Li Scott Happell Guohui Xie Krishna C. Vutukuri Wiley Publishing, Inc. Kumaravel ffirs.tex V1 - 01/09/2008 8:43pm Page iv Windows PowerShell  Programming: Snap-ins, Cmdlets, Hosts, and Providers Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright  2008 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-17393-0 Manufactured in the United States of America 10987654321 Library of Congress Cataloging-in-Publication Data 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 Legal Department, Wiley Publishing, Inc., 10475 Crosspoint Blvd., Indianapolis, IN 46256, (317) 572-3447, fax (317) 572-4355, or online at http://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 Website 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 Website may provide or recommendations it may make. Further, readers should be aware that Internet Websites 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 (800) 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. Windows PowerShell is a trademark 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. Kumaravel fauth.tex V2 - 01/07/2008 10:17pm Page v About the Author Arul Kumaravel is currently the Development Manager of the Windows PowerShell team. He has worked with this team since its early days and led the team in shipping of version 1 of the product, and is presently leading the development of next version of PowerShell. Fascinated by computers from an early age, when he first learned programming using BASIC, he went on to get his Master of Science degree in Computer Science from both the College of Engineering, Madras, India, and the University of Iowa. As a Microsoft intern, he wrote the first JavaScript/VBScript debugger for Internet Explorer 3, and was impressed by the potential to make a difference in millions of people’s lives by working for Microsoft. He has been working at Microsoft for the past 11 years in various groups, shipping multiple versions of products, including Internet Explorer, the Windows operating system, and Content Manage- ment Server, and has even dabbled with Software as a Service with small business online services. More recently, attracted by the business side of technology, Arul has taken on the arduous task of pursuing his M.B.A. at the Wharton Business School. He can be reached at arulk@hotmail.com . Jon White is a software engineer who lives and works in the idyllic surroundings of Seattle’s eastern suburbs. An original member of the PowerShell team at Microsoft, his professional career started in the Administrative Tools group in Windows Server. As a hobbyist, Jon learned programming in his early teens after his father bought an 8088-based PC clone at a second-hand shop. The PC came with MS-DOS 2.0, which featured debug.exe with a 16-bit disassembler, but no assembler. As a result, Jon’s first dive into programming was disassembling long tables of bytes to create a reverse-lookup dictionary for manually converting assembly programs into executable binary code. Coincidentally, later in life he filed the bug which removed debug.exe from 64-bit Windows. As a member of the PowerShell team, he wrote the language’s first production script, when he converted the team’s test harness from Perl to PowerShell script in 2004. When he’s not working (or writing about work) he’s either sailing or playing with fire in the backyard. You can contact him at jwh@microsoft.com . Michael Naixin Li is the Senior Test Lead working on the Windows PowerShell team and currently oversees the testing of Windows PowerShell 2.0. Before Windows PowerShell, Michael worked on vari- ous major projects at Microsoft, including the development of MSN 1.x and 2.x, quality management for the COM Services component in Windows 2000, NetDocs Web Client Access, Web Services in Hailstorm, and Software Licensing Service in Windows Vista. Before joining Microsoft, Michael was an assistant professor at Shanghai University of Science and Technology (now called ShanghaiUniversity).Heholds a Ph.D. in Computer Science from Colorado State University. Scott Happell has been working as a software engineer and tester for 10 years. Three of those years have been on the Windows PowerShell team, which was what brought him to Microsoft from New Jersey, where he worked at an Internet startup that went belly-up. Scott recently left Microsoft to become a recording engineer/rock star and is trying to find cool ways to use PowerShell to help him create music. George Xie was a Senior Developer in the Windows PowerShell team for three years, mainly focusing in the area of snap-in model and scripting language. Recently George joined Windows Mobile organi- zation for the Mobile Device Management product. Before joining Microsoft, George worked for Siebel Systems Inc. for several years. Krishna Chythanya Vutukuri is a Software Developer working on the Windows PowerShell team. Before Windows PowerShell, Krishna worked on various projects at Microsoft, which included the development of Windows Presentation Foundation. Before joining Microsoft, Krishna held various product develop- ment positions at Hewlett-Packard India Software Operations and Wipro Technologies. He holds a M.Sc (Tech.) in Information Systems from Birla Institute of Technology and Science, Pilani, India. Kumaravel fauth.tex V2 - 01/07/2008 10:17pm Page vi Kumaravel fcredit.tex V1 - 01/07/2008 10:18pm Page vii Credits Executive Editor Chris Webb Development Editor Howard Jones Technical Editor Marco Shaw Production Editor Rachel McConlogue Copy Editor Luann Rouff Editorial Manager Mary Beth Wakefield Production Manager Tim Tate Vice President and Executive Group Publisher Richard Swadley Vice President and Executive Publisher Joseph B. Wikert Project Coordinator, Cover Lynsey Osborn [...]... Chapter 1: Introduction to PowerShell 1 Windows PowerShell Design Principles 1 Preserve the Customer’s Existing Investment Provide a Powerful, Object-Oriented Shell Extensibility, Extensibility, Extensibility Tear Down the Barriers to Development A Quick Tour of Windows PowerShell Cmdlets High-Level Architecture of Windows PowerShell Host Application Windows PowerShell Engine Windows PowerShell Snap-ins 2... Summary 11 Chapter 2: Extending Windows PowerShell 13 Types of PowerShell Snap-ins Creating a Standard PowerShell Snap-in 13 14 Writing a PowerShell Snap-in Registering Your PowerShell Snap-in Listing Available PowerShell Snap-ins Loading a PowerShell Snap-in to a Running Shell Removing a PowerShell Snap-in from a Running Shell Unregistering a PowerShell Snap-in Registering a PowerShell Snap-in without... handling, and debugging and tracing capabilities A Quick Tour of Windows PowerShell This section presents a quick tour of Windows PowerShell We’ll start with a brief look at installing the program, and then move right into a discussion of cmdlets You start Windows PowerShell either by clicking the Windows PowerShell shortcut link or by typing PowerShell in the Run dialog box (see Figure 1-1) Figure 1-1:... associated with writing command-line utilities, Windows PowerShell enables developers to focus on the business logic of their application, rather than spend development time solving universal problems Windows PowerShell Design Principles Windows PowerShell was designed in response to years of customer feedback about the administrative experience on Microsoft Windows Early on, many users asked why some... Introduction to PowerShell Welcome to Windows PowerShell, the new object-based command-line interface shell and scripting language built on top of NET PowerShell provides improved control and automation of IT administration tasks for the Windows platform It is designed to make IT professionals and developers more productive Several books that introduce end-user IT professionals to Windows PowerShell are... following three years, would become Windows PowerShell Version 1, available for download on the web and as an optional component on Windows Server 2008, provides a rich programming environment for users of every stripe, and for the first time gives Windows users a consistent glide path from the command-line experience all the way to COM and beyond This book is intended for the PowerShell snap-in and host developer... executables, but a cmdlet is an instance of a NET class, and runs within PowerShell s process 3 Page 3 Kumaravel c01.tex V2 - 01/07/2008 Chapter 1: Introduction to PowerShell Windows PowerShell provides a rich set of cmdlets, including several that enhance the discoverability of the shell’s features We begin our tour of Windows PowerShell by learning about a few cmdlets that will help you get started... available, but PowerShell development from the perspective of cmdlet, provider, and host developers has gone largely unmentioned This book attempts to fill that gap by introducing the reader to the concepts, components, and development techniques behind building software packages that leverage Windows PowerShell This book is written for developers who want to extend the functionality of Windows PowerShell. .. throw out their existing investments, which is why PowerShell was designed from the ground up to be compatible with existing Windows Management technologies In fact, PowerShell runs existing commands and scripts seamlessly You can make use of PowerShell s integration with COM, WMI, and ADSI technologies alongside its tight integration with NET Indeed, PowerShell is the only technology that enables you... Welcome to Professional Windows PowerShell Programming Way back in 2003, I attended a talk at a conference center at Microsoft by some engineers from the Microsoft Management Console team who were giving a demonstration of a prototype enhancement to MMC The prototype was one of the early murmurs of Microsoft’s response to the deluge of customer feedback they’d received about the Windows administrative . Tour of Windows PowerShell 3 Cmdlets 3 High-Level Architecture of Windows PowerShell 9 Host Application 9 Windows PowerShell Engine 10 Windows PowerShell. Test Lead working on the Windows PowerShell team and currently oversees the testing of Windows PowerShell 2.0. Before Windows PowerShell, Michael worked

Ngày đăng: 13/12/2013, 02:16

TỪ KHÓA LIÊN QUAN