Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Windows PowerShell Scripting

You're reading from   Mastering Windows PowerShell Scripting Automate and manage your environment using PowerShell Core 6.0

Arrow left icon
Product type Paperback
Published in Feb 2019
Publisher Packt
ISBN-13 9781789536669
Length 626 pages
Edition 3rd Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Chris Dent Chris Dent
Author Profile Icon Chris Dent
Chris Dent
Arrow right icon
View More author details
Toc

Table of Contents (27) Chapters Close

Preface 1. Section 1: Exploring PowerShell Fundamentals FREE CHAPTER
2. Introduction to PowerShell 3. Modules and Snap-ins 4. Working with Objects in PowerShell 5. Operators 6. Section 2: Working with Data
7. Variables, Arrays, and Hashtables 8. Branching and Looping 9. Working with .NET 10. Strings, Numbers, and Dates 11. Regular Expressions 12. Files, Folders, and the Registry 13. Windows Management Instrumentation 14. HTML, XML, and JSON 15. Web Requests and Web Services 16. Section 3: Automating with PowerShell
17. Remoting and Remote Management 18. Asynchronous Processing 19. Section 4: Extending PowerShell
20. Scripts, Functions, and Filters 21. Parameters, Validation, and Dynamic Parameters 22. Classes and Enumerations 23. Building Modules 24. Testing 25. Error Handling 26. Other Books You May Enjoy

Classes and Enumerations

PowerShell 5 introduced support for creating classes and enumerations within PowerShell directly. Prior to this, classes had to be imported from an assembly written in a language such as C#, or dynamically created using the dynamic module builders.

Classes and enumerations are undergoing a great deal of change in PowerShell Core. There are numerous enhancement issues open in the PowerShell project on GitHub that are slowly making their way into PowerShell Core. Examples include the addition of interfaces, support for using validation attributes on properties, and the ability to override getters and setters for properties.

This chapter will explore the following topics:

  • Defining an enumeration
  • Creating a class
  • Argument transformation attribute classes
  • Validation attribute classes
  • Classes and DSC
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime