Working with .NET

PowerShell is written in and built on the .NET Framework. Much of the .NET Framework can be used directly, and doing so adds a tremendous amount of flexibility by removing many of the borders the language might otherwise have.

The idea of working with objects was introduced in Chapter 3, Working with Objects in Powershell, and this chapter extends on that, moving from objects created by commands to objects created from .NET classes. Many of the chapters that follow this one make extensive use of .NET, simply because it's the foundation of PowerShell.

It's important to understand that the .NET Framework is vast; it isn't possible to cover everything about the .NET Framework in a single chapter. This chapter aims to show how the .NET Framework may be used within PowerShell based on the MSDN reference, which is available at https://docs.microsoft.com/en-us/dotnet/api/index?view=netframework-4.7.2.

What can you do with .NET?

I enjoy implementing network protocols in PowerShell. To do this, I use several branches of .NET that specialize in network operations, such as creating sockets, sending and receiving bytes, and reading and converting streams of bytes.

Classes implemented in .NET will come up again and again as different areas of the language are explored. From building strings and working with Active Directory, to writing graphical interfaces and working with web services, everything needs a little .NET.

In this chapter, we're going to cover the following topics:

  • Assemblies
  • Namespaces
  • Types
  • Classes
  • Constructors
  • Properties and methods
  • Static properties
  • Static methods
  • Non-public classes
  • Type accelerators
  • The using keyword
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.107.90