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.
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.
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.
For this example, if you are using PowerShell v2 you’ll need to start with the ...