Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET class documentation from within PowerShell?

Is there a convenient method to access .NET class documentation (i.e. the MSDN documentation) from within PowerShel similar to "man 3" in UNIX shells?

like image 833
Andrew J. Brehm Avatar asked Jan 15 '10 16:01

Andrew J. Brehm


People also ask

What is the use of PowerShell classes?

The addition of classes enables developers and IT professionals to embrace PowerShell for a wider range of use cases. It simplifies development of PowerShell artifacts and accelerates coverage of management surfaces. A class declaration is a blueprint used to create instances of objects at run time.

How do I create a class in PowerShell?

PowerShell has the capability to create .Net Framework classes using the Add-Type cmdlet. To create classes, the C# language can be used to define the classes. C# is part of Visual Studio, but having Visual Studio is not necessary to create classes for use in PowerShell.

When should I use a native PowerShell cmdlet?

It is always a best practice, to use a native Windows PowerShell cmdlet when it exists unless there is a good reason for not doing so. One such example is using a static method within a .NET class. To determine the power of a number we make use of System.Math class and use the method Pow

How do I load a DLL file in PowerShell?

Firstly you need to download .dll into powershell session: [System.Reflection.Assembly]::LoadFile("c:\script ame.dll") Share Improve this answer Follow answered May 29 '17 at 12:37 Mihail KuznesovMihail Kuznesov 51622 silver badges1212 bronze badges 2 Add-Type -AssemblyNameis the preferred way to load .Net assemblies. – vonPryz


1 Answers

In the Powershell Community Extensions 2.0 (still only available via daily builds), we extend Get-Help to add a -object parameter that, in conjunction with -online, will bring up MSDN documentation e.g.:

Get-Help -object (get-date) -online

Until we release a 2.0 beta (in a few weeks), grab the module file from here. Note that it requires features in PowerShell 2.0. Import this module like so:

Import-Module .\Pscx.GetHelp.psm1

Note that you can't use this on a namespace like System.Net but pick a type like System.Net.WebClient e.g.:

Get-Help -obj [System.Net.WebClient] -online

BTW, gives props to x0n (Oisin) for implementing this for PSCX.

like image 94
Keith Hill Avatar answered Oct 23 '22 05:10

Keith Hill