15.3. Exploring the Current Application Domain

Another aspect of the environment that Windows PowerShell allows you to explore is the application domain. An application domain is represented by the .NET System.AppDomain class. An application domain provides isolation, unloading, and security boundaries for executing managed code. This can be useful where a software module is running in relation to a process. If the software module crashes but is running in a separate application domain, it is possible to unload the application domain with the crashed software module without adversely affecting the execution of the process.

You can find out the current application domain using the get_CurrentDomain() method or the CurrentDomain property of the System.AppDomain class. Either of the following commands assigns an object representing the current domain to the variable $CurrDomain:

$CurrDomain = [System.AppDomain]::get_CurrentDomain()

or:

$CurrDomain = [System.AppDomain]::CurrentDomain

To display basic information about the current application domain, you can simply type:

$CurrDomain

Figure 15-18 shows the information about the current application domain on one of the computers I am using to write this book.

Figure 15.18. Figure 15-18

As always, you can find the members of an object using the get-member cmdlet. The following command finds the members of the $CurrDomain object:

$CurrDomain ...

Get Professional Windows® PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.