O'Reilly logo

Windows PowerShell for Developers by Douglas Finke

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 8. DLLs, Types, Properties, Methods, and Microsoft Roslyn

How do you learn to work with PowerShell, the .NET Framework, your .NET DLLs, third-party .NET DLLs, and other Microsoft and non-Microsoft libraries? In this chapter, I’ll step you through how to load DLLs and discover the types, properties, and methods that you can call during a live interactive session.

Note

When you’re working with the .NET Framework, your best friend is the MSDN Library (http://msdn.microsoft.com/en-us/library/). It’s an essential source of information for developers using Microsoft tools, products, technologies, and services.

For example, if I search for “programmatically put data on the clipboard MSDN,” I find the page “Clipboard Class (System.Windows)” (http://bit.ly/GJuNcS). This page details all the information I need—specifically the assembly needed to load (PresentationCore), the fully qualified type name (namespace and class) needed to call System.Windows.Clipboard, and a list of the methods that are available to use.

Sending Text to the Clipboard

To kick this section off, we’ll create a PowerShell function to put the text “Hello World” on the clipboard. I’ll show you how to use Get-Member to list out method names at the command line so you can discover them in your current session. This is a convenient technique that can speed development when you need to find out what methods exist on an object you are using.

Note

For this example, if you are using PowerShell v2 you’ll need to start with the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required