Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Get Cmdlet Help URL

Posted on April 2, 2012

I was toying around with PowerShell help this morning and as usually happens one thing leads to another. When you run Get-Help, or use the wrapper function Help, you are actually getting an object: MamlCommandHelpInfo. This object has properties that you are use to seeing like name and synopsis.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!


PS C:\> get-help get-service | Select Name,Syntax,RelatedLinks

Name syntax relatedLinks
---- ------ ------------
Get-Service @{syntaxItem=System.Man... @{navigationLink=Syste...

As you can see, some of these properties are nested objects.


PS C:\> get-help get-service | Select RelatedLinks | get-member

TypeName: Selected.System.Management.Automation.PSCustomObject

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
relatedLinks NoteProperty MamlCommandHelpInfo#relatedLinks relatedLinks=@{na...

I wanted to try something with related links, specifically those links which PowerShell uses for online help.


PS C:\> get-help get-service | Select -expandproperty RelatedLinks

Online version: http://go.microsoft.com/fwlink/?LinkID=113332
Start-Service
Stop-Service
Restart-Service
Resume-Service
Suspend-Service
Set-Service
New-Service

It is easy to forget, that these are still objects.


PS C:\> get-help get-service | Select -expandproperty RelatedLinks | get-member

TypeName: MamlCommandHelpInfo#relatedLinks

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
navigationLink NoteProperty System.Management.Automation.PSObject[] navigati...

I see that these related link objects have a NavigationLink property so I'll expand it:


PS C:\> get-help get-service | Select -expandproperty RelatedLinks | select -e
xpand navigationlink

linkText uri
-------- ---
Online version: http://go.microsoft.com/fwlink/?Link...
Start-Service
Stop-Service
Restart-Service
Resume-Service
Suspend-Service
Set-Service
New-Service

Now we're getting somewhere. All I want is the link with a URI value.


PS C:\> get-help get-service | Select -expandproperty RelatedLinks | select -expandproperty navigationlink | where {$_.uri}

linkText uri
-------- ---
Online version: http://go.microsoft.com/fwlink/?Link...

Very cool. Now that I have the basic concept down for a single cmdlet, I can modify my expression to pull this value out of the nested objects and bring it "up".


Get-Help get-service |
Select Name,Synopsis,@{Name="URI";Expression={
($_.RelatedLinks | select -ExpandProperty NavigationLink | where {$_.uri}).uri}} |
Where {$_.URI}

I'm using a hash table to define a custom property called URI that pulls the URI property, if found "up". When I run this code and pipe it to Format-List to make it easier to read I get a result like this:


Name : Get-Service
Synopsis : Gets the services on a local or remote computer.
URI : http://go.microsoft.com/fwlink/?LinkID=113332

Beautiful. All I need to do now is modify my code to work with more cmdlets.


Get-Command -CommandType cmdlet | Get-Help | Select Name,Synopsis,@{Name="URI";Expression={
($_.RelatedLinks | select -ExpandProperty NavigationLink | where {$_.uri}).uri}} | Where {$_.URI}

This one line command will get all cmdlets in my current PowerShell session and display the cmdlet name, synopsis and help URL if found. The PowerCLI cmdlets include online help, but not all of them so when I run this command in a session with them loaded I'll only get those cmdlets with an online help link.

What I really wanted to show here is discovering an object's details, especially if there are nested object properties. PowerShell is all about objects in the pipeline and once you get a hold of that concept you can do some amazing things with very little effort. I'll be back tomorrow to take this one more step.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

1 thought on “Get Cmdlet Help URL”

  1. Pingback: Create an HTML PowerShell Help Page | The Lonely Administrator

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d