ESSENTIAL POWERSHELL Holger

Total Page:16

File Type:pdf, Size:1020Kb

ESSENTIAL POWERSHELL Holger ESSENTIAL POWERSHELL This page intentionally left blank ESSENTIAL POWERSHELL Holger Schwichtenberg Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Cape Town • Sydney • Tokyo • Singapore • Mexico City Many of the designations used by manufacturers and sellers to distinguish their products are Editor-in-Chief claimed as trademarks. Where those designations appear in this book, and the publisher was Karen Gettman aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals. Executive Editor Neil Rowe The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions. No liability Development is assumed for incidental or consequential damages in connection with or arising out of the use of Editor the information or programs contained herein. Mark Renfrow The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases Managing Editor or special sales, which may include electronic versions and/or custom covers and content partic- Kristy Hart ular to your business, training goals, marketing focus, and branding interests. For more informa- tion, please contact: Project Editor U.S. Corporate and Government Sales Betsy Harris (800) 382-3419 Copy Editor [email protected] Keith Cline For sales outside the United States please contact: Indexer International Sales Publishing Works, [email protected] Inc. Visit us on the Web: www.informit.com/aw Proofreader Library of Congress Cataloging-in-Publication Data Paula Lowell Schwichtenberg, Holger. Technical Editor Essential PowerShell / Holger Schwichtenberg. Tony Bradley p. cm. ISBN 978-0-672-32966-1 Publishing 1. Windows PowerShell (Computer programming language) 2. Command languages Coordinator (Computer science) 3. Scripting languages (Computer science) 4. Systems programming Cindy Teeters (Computer science) 5. Microsoft Windows (Computer file) I. Title. QA76.73.W56S39 2008 Cover Designer 005.4’2—dc22 Gary Adair 2008020010 Compositor Copyright © 2008 by Pearson Education, Inc. Nonie Ratcliff All rights reserved. Printed in the United States of America. This publication is protected by copy- right, and permission must be obtained from the publisher prior to any prohibited reproduction, storage in a retrieval system, or transmission in any form or by any means, electronic, mechani- cal, photocopying, recording, or likewise. For information regarding permissions, write to: Pearson Education, Inc Rights and Contracts Department 501 Boylston Street, Suite 900 Boston, MA 02116 Fax (617) 671 3447 ISBN-13: 978-0-672-32966-1 ISBN-10: 0-672-2966-2 Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana. First printing June 2008 To Heidi, the woman I love. This page intentionally left blank CONTENTS Preface . xv Acknowledgments . xix About the Author . xxi PART I: GETTING STARTED WITH POWERSHELL . 1 Chapter 1: First Steps with Windows PowerShell . 3 What Is Windows PowerShell? . 3 Downloading and Installing PowerShell Community Extensions . 16 Testing the PowerShell Extensions . 18 Downloading and Installing the PowerShellPlus . 19 Testing the PowerShell Editor . 20 Summary . 22 Chapter 2: Commandlets . 25 Introducing Commandlets . 25 Aliases . 29 Expressions . 32 External Commands . 33 Getting Help . 35 Summary . 41 vii viii Contents Chapter 3: Pipelining . 43 Pipelining Basics . 43 Pipeline Processor . 47 Complex Pipelines . 48 Output . 49 Getting User Input . 56 Summary . 58 Chapter 4: Advanced Pipelining . 59 Analyzing Pipeline Content . 59 Filtering Objects . 70 Castrating Objects . 73 Sorting Objects . 74 Grouping Objects . 74 Calculations . 76 Intermediate Steps in the Pipeline . 76 Comparing Objects . 78 Ramifications . 78 Summary . 79 Chapter 5: The PowerShell Navigation Model . 81 Navigation through the Registry . 81 Providers and Drives . 83 Navigation Commandlets . 84 Paths . 85 Defining Drives . 87 Summary . 88 Chapter 6: The PowerShell Script Language . 89 Getting Help . 90 Command Separation . 90 Comments . 90 Variables . 91 Available Types . 92 Numbers . 96 Random Numbers . 98 Contents ix Strings . 99 Date and Time . 102 Arrays . 105 Associative Arrays (Hash Tables) . 106 Operators . 108 Control Structures . 110 Summary . 113 Chapter 7: PowerShell Scripts . 115 A First PowerShell Script Example . 115 Start a PowerShell Script . 117 Including Scripts . 118 Scripting Security . 118 Signing of Scripts . 120 Letting a Script Sleep . 122 Errors and Error Treatment . 122 Summary . 128 Chapter 8: Using Class Libraries . 129 Using .NET Classes . 129 Using COM Classes . 133 Using WMI Classes . 135 Date and Time . 145 Summary . 150 Chapter 9: PowerShell Tools . 151 PowerShell Console . 151 PowerTab . 156 PowerShell IDE . 156 Windows PowerShellPlus . 158 PowerShell Analyzer . 164 PrimalScript . 165 PowerShell Help . 169 Summary . ..
Recommended publications
  • Common Tasks
    Common Tasks • Browser Settings for Internet Explorer, on page 1 • Browser Settings for Firefox, on page 2 • Sign In to Finesse Desktop, on page 3 • Accept Security Certificates, on page 4 • Accept Certificates for Live Data Gadget, on page 6 • Accept Certificates for Multi-session Chat and Email, on page 7 • Sign Out of the Finesse Desktop, on page 7 • Live Data Reports, on page 8 • View My History, on page 9 • View Context Service Data, on page 10 Browser Settings for Internet Explorer If Internet Explorer is used to access the Finesse desktop, certain settings must be configured in the browser to ensure all features of Finesse work properly. 1. Disable pop-up blockers. Finesse does not support Compatibility View. Make sure the desktop is not running in Compatibility View. 2. Configure the following privacy and advanced settings: a. From the browser menu, select Tools > Internet Options. b. Click the Privacy tab. c. Click Sites. d. In the Address of website box, enter the domain name for the Side A Finesse server. e. Click Allow. f. In the Address of website box, enter the domain name for the Side B Finesse server. g. Click Allow. h. Click OK. Common Tasks 1 Common Tasks Browser Settings for Firefox 3. You must enable the following security settings to allow users to sign in: • Run ActiveX controls and plug-ins • Script ActiveX controls marked as safe for scripting • Active scripting To enable these settings: a. From the Internet Explorer browser menu, select Tools > Internet Options. b. Click the Security tab. c. Click Custom level.
    [Show full text]
  • List of TCP and UDP Port Numbers
    List of TCP and UDP port numbers From Wikipedia, the free encyclopedia Jump to: navigation, search This is a list of Internet socket port numbers used by protocols of the Transport Layer of the Internet Protocol Suite for the establishment of host-to-host communications. Originally, these port numbers were used by the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP), but are used also for the Stream Control Transmission Protocol (SCTP), and the Datagram Congestion Control Protocol (DCCP). SCTP and DCCP services usually use a port number that matches the service of the corresponding TCP or UDP implementation if they exist. The Internet Assigned Numbers Authority (IANA) is responsible for maintaining the official assignments of port numbers for specific uses.[1] However, many unofficial uses of both well- known and registered port numbers occur in practice. Contents [hide] y 1 Table legend y 2 Well-known ports: 0±1023 y 3 Registered ports: 1024±49151 y 4 Dynamic, private or ephemeral ports: 49152±65535 y 5 See also y 6 References y 7 External links [edit] Table legend Color coding of table entries Official Port/application combination is registered with IANA Unofficial Port/application combination is not registered with IANA Conflict Port is in use for multiple applications [edit] Well-known ports: 0±1023 The port numbers in the range from 0 to 1023 are the well-known ports. They are used by system processes that provide widely-used types of network services. On Unix-like operating systems, a process must execute with superuser privileges to be able to bind a network socket to an IP address using one of the well-known ports.
    [Show full text]
  • Operational and Administrative Guidance Microsoft Windows 10
    Operational and Administrative Guidance Microsoft Windows 10 and Windows Server Common Criteria Evaluation for Microsoft Windows 10 and Windows Server Version 1803 General Purpose Operating System Protection Profile © 2018 Microsoft Confidential. All rights reserved. Microsoft Windows 10 GP OS Administrative Guidance Copyright and disclaimer The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. This work is licensed under the Creative Commons Attribution-NoDerivs-NonCommercial VLicense (which allows redistribution of the work). To view a copy of this license, visithttp://creativecommons.org/licenses/by-nd-nc/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. The example companies, organizations, products, people and events depicted herein are fictitious. No association with any real company, organization, product, person or event is intended or should be inferred.
    [Show full text]
  • Microsoft Windows Server 2019 Version 1809 Hyper-V
    Operational and Administrative Guidance Microsoft Windows Server, Microsoft Windows 10 version 1909 (November 2019 Update), Microsoft Windows Server 2019 version 1809 Hyper-V Common Criteria Evaluation under the Protection Profile for Virtualization, including the Extended Package for Server Virtualization Revision date: January 15, 2021 © 2021 Microsoft. All rights reserved. Microsoft Windows Server and Windows 10 Hyper-V Administrative Guidance Copyright and disclaimer The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. This work is licensed under the Creative Commons Attribution-NoDerivs-NonCommercial VLicense (which allows redistribution of the work). To view a copy of this license, visithttp://creativecommons.org/licenses/by-nd-nc/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. The example companies, organizations, products, people and events depicted herein are fictitious.
    [Show full text]
  • IBM Connect:Direct for Microsoft Windows: Documentation Fixpack 1 (V6.1.0.1)
    IBM Connect:Direct for Microsoft Windows 6.1 Documentation IBM This edition applies to Version 5 Release 3 of IBM® Connect:Direct and to all subsequent releases and modifications until otherwise indicated in new editions. © Copyright International Business Machines Corporation 1993, 2018. US Government Users Restricted Rights – Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. Contents Chapter 1. Release Notes.......................................................................................1 Requirements...............................................................................................................................................1 Features and Enhancements....................................................................................................................... 2 Special Considerations................................................................................................................................ 3 Known Restrictions...................................................................................................................................... 4 Restrictions for Connect:Direct for Microsoft Windows........................................................................ 4 Restrictions for Related Software.......................................................................................................... 6 Installation Notes.........................................................................................................................................6
    [Show full text]
  • Dell Server Administrator Installation Version 7.4 Release Notes
    Server Administrator Installation and Management 7.4.0 Release Notes Version 7.4.0 Release Date: March 2014 Previous Version 7.3.0 Importance RECOMMENDED: Dell recommends applying this update during your next scheduled update cycle. The update contains feature enhancements or changes that will help keep your system software current and compatible with other system modules (firmware, BIOS, drivers and software). What’s New • Intel and Broadcom SNMP Agents 64-bit versions are available as part of the 64-bit server administrator installer. • srvadmin-cm RPM 64-bit version is available as part of the 64-bit Linux installer stack for all supported Linux flavors. Installation • To install Server Administrator on Windows Server 2008 R2 SP1 Core and Windows Server 2012 Core, Windows-on-Windows (WOW) mode must be enabled. • On Microsoft Windows operating systems, run setup.exe from the SYSMGMT\srvadmin\windows directory of the DVD or the software package. Note: This step is not necessary if the DVD runs automatically. • On the Red Hat Enterprise Linux and SUSE Linux Enterprise Server operating systems, to perform an Express Install, execute srvadmin-install.sh -x from the SYSMGMT/srvadmin/linux/supportscripts directory For more information on installation instructions, including silent installation options, see the Server Administrator Installation Guide. User Notes for Supported Windows Operating Systems In the Prerequisite Checker screen, you may get the following message: An error occurred while attempting to execute a Visual Basic Script. Please confirm that Visual Basic files are installed correctly. This error occurs when the Prerequisite Checker calls the vbstest.vbs (a Visual Basic [VB]) script to verify the installation environment and fails for some reason.
    [Show full text]
  • Planning for Internet Explorer and the IEAK
    02_Inst.fm Page 15 Monday, October 16, 2000 9:40 AM TWO 2Chapter 2 Planning for Internet Explorer and the IEAK LChapter Syllabus In this chapter, we will look at material covered in the Planning section of Microsoft’s Implementing MCSE 2.1 Addressing Technical Needs, Rules, and Policies and Supporting Microsoft Internet Explorer 5 by using the Internet Explorer Administration Kit exam MCSE 2.2 Planning for Custom (70-080). After reading this chapter, you should be Installations and Settings able to: MCSE 2.3 Providing Multiple • Identify and evaluate the technical needs of business Language Support units, such as Internet Service Providers (ISPs), con- tent providers, and corporate administrators. MCSE 2.4 Providing Multiple Platform Support • Design solutions based on organizational rules and policies for ISPs, content providers, and corporate MCSE 2.5 Developing Security Strategies administrators. • Evaluate which components to include in a custom- MCSE 2.6 Configuring for Offline ized Internet Explorer installation package for a given Viewing deployment scenario. MCSE 2.7 Replacing Other Browsers • Develop appropriate security strategies for using Internet Explorer at various sites, including public MCSE 2.8 Developing CMAK kiosks, general business sites, single-task-based sites, Strategies and intranet-only sites. 15 02_Inst.fm Page 16 Monday, October 16, 2000 9:40 AM 16 Chapter 2 • Planning for Internet Explorer and the IEAK • Configure offline viewing for various types of users, including gen- eral business users, single-task users, and mobile users. • Develop strategies for replacing other Internet browsers, such as Netscape Navigator and previous versions of Internet Explorer. • Decide which custom settings to configure for Microsoft Outlook Express for a given scenario.
    [Show full text]
  • *Library/ Mentoring/ Association/ Club Activities *Library/ Mentoring
    REGULATION 2020-21 B.Sc. INFORMATION TECHNOLOGY SEMSTER III B.Sc. INFORMATION TECHNOLOGY SL. COMPONENTS HOURS CREDITS PART III CORE SUBJECTS 1. Numerical Method and Operation Research 4 4 2. Object Oriented Programming with C++ 4 4 3. Object Oriented Programming with C++ - LAB 6 3 ALLIED SUBJECTS - 1 4. Data Structure 4 4 5. Data Structure – LAB 4 2 6. Skill Based Core Subject – I DTP 5(IT+4P) 4 7. Non – Major Elective – I 2 2 8. Common Yoga -- 2 TOTAL (5T + 3P = 8 COURSE) 30* 25 *Library/ Mentoring/ Association/ Club Activities SEMSTER IV B.Sc. INFORMATION TECHNOLOGY SL. COMPONENTS HOURS CREDITS PART III CORE SUBJECTS 1. Java Programming 4 4 2. Java Programming Lab 6 3 3. Operating System 4 4 ALLIED SUBJECTS - 1 4. Relational Data Base Management System 4 4 5. ORACLE – LAB 4 2 6. Skill Based Core Subject – II VISUAL PROGRAMMING 5(2T+3P) 4 7. Non – Major Elective – II 2 2 8. Computers for Digital Era -- 2 9. Extension Activity -- 1 10. Library Mentoring and Associations 1 -- TOTAL (5T + 3P = 8 COURSE) 30* 26 *Library/ Mentoring/ Association/ Club Activities SEMSTER V B.Sc. INFORMATION TECHNOLOGY SL. COMPONENTS HOURS CREDITS PART III CORE SUBJECTS 1. Scripting Language 4 4 2. Software Engineering and Testing 4 4 3. Data Communication and Networking 4 4 4. Scripting Language – LAB 6 3 5. Major Elective – I (Group – A) 4 4 Skill Based Common Subject – 6. Personality Development /Effective Communication/Youth 2 2 Leadership 7. Mini Project 5 5 TOTAL (5T + 1P + 1Project = 7 COURSE) 30* 26 *Library/ Mentoring/ Association/ Club Activities SEMSTER VI B.Sc.
    [Show full text]
  • Operational and Administrative Guidance
    Operational and Administrative Guidance Microsoft Windows Server, Microsoft Windows 10 version 1909 (November 2019 Update), Microsoft Windows Server 2019 version 1809 Hyper-V Common Criteria Evaluation under the Protection Profile for Virtualization, including the Extended Package for Server Virtualization Revision date: January 15, 2021 © 2021 Microsoft. All rights reserved. Microsoft Windows Server and Windows 10 Hyper-V Administrative Guidance Copyright and disclaimer The information contained in this document represents the current view of Microsoft Corporation on the issues discussed as of the date of publication. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO THE INFORMATION IN THIS DOCUMENT. Complying with all applicable copyright laws is the responsibility of the user. This work is licensed under the Creative Commons Attribution-NoDerivs-NonCommercial VLicense (which allows redistribution of the work). To view a copy of this license, visithttp://creativecommons.org/licenses/by-nd-nc/1.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. The example companies, organizations, products, people and events depicted herein are fictitious.
    [Show full text]
  • Making Access Project and Data Technologies Choices
    05 0672321025 CH03 8/10/01 8:20 AM Page 71 Making Access Project and CHAPTER Data Technologies Choices 3 IN THIS CHAPTER • Using Microsoft Database Versus Access Database Project 72 • Using DAO Versus ADO Versus XML 75 05 0672321025 CH03 8/10/01 8:20 AM Page 72 The Root of Power Programming 72 PART I Before Access 2000, when you created an application, you had to plan whether you wanted to use a Jet (the database engine Access uses natively) or a client/server back end. Depending on the type of back end chosen, you would use various methods to create the application. Although this is still the case, you now have more choices to make when starting on a project. Now, in addition to the back-end choice, you must decide what type of database container to use: the traditional MDB or ADP. The other choice to make is the method of accessing the data while working in VBA: DAO (Data Access Objects), which has been used since Access 2, or ADO (ActiveX Data Objects), the data-access technology now used throughout a number of Microsoft products, including Visual InterDev. You now have an additional choice of XML (Extensible Markup Language), which transfers data between systems and applications. Helping you decide which technology to use in which case is what this chapter is all about. When you first look at the choices, it’s hard to see when one should be used over another. NOTE This chapter isn’t intended as an in-depth discussion of these technologies.
    [Show full text]
  • Oracle® Provider for OLE DB Developer's Guide
    Oracle® Provider for OLE DB Developer's Guide 19c for Microsoft Windows E96615-01 May 2019 Oracle Provider for OLE DB Developer's Guide, 19c for Microsoft Windows E96615-01 Copyright © 1999, 2019, Oracle and/or its affiliates. All rights reserved. Primary Author: Maitreyee Chaliha Contributing Authors: Janis Greenberg, Alex Keh, Eric Belden, Riaz Ahmed, Kiminari Akiyama, Christian Shay, Valarie Moore, Neeraj Gupta, Sinclair Hsu, Gopal Kirsur, Sunil Mushran, Rajendra Pingte, Helen Slattery, Vikhram Shetty, Sujith Somanathan, Mark Williams This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, then the following notice is applicable: U.S. GOVERNMENT END USERS: Oracle programs, including any operating system, integrated software, any programs installed on the hardware, and/or documentation, delivered to U.S. Government end users are "commercial computer software" pursuant to the applicable Federal Acquisition Regulation and agency- specific supplemental regulations.
    [Show full text]
  • Database Connectivity Toolkit for Fast Transactions User Manual
    Database Connectivity Toolkit for Fast Transactions User Manual Ovak Technologies 2016 Contents 1. Introduction ......................................................................................................................................... 3 1.1. Definitions and Acronyms ............................................................................................................ 3 1.2. Purpose .......................................................................................................................................... 3 1.3. Overview ....................................................................................................................................... 3 2. Open Database Connectivity (ODBC) ............................................................................................... 4 3. Registering ODBC Driver .................................................................................................................. 5 3.1. Opening the ODBC Driver Manager ............................................................................................. 5 3.2. Configuring the default DSN entry ............................................................................................... 6 3.3. Adding a new DSN entry .............................................................................................................. 7 3.4. Removing an existing DSN entry .................................................................................................. 8 4. Connecting to a Database ..................................................................................................................
    [Show full text]