Skip to content

Instantly share code, notes, and snippets.

@corbob
Created August 31, 2018 06:23
Show Gist options
  • Select an option

  • Save corbob/4845bcd19b251d41fe9b4fb5fea99ef6 to your computer and use it in GitHub Desktop.

Select an option

Save corbob/4845bcd19b251d41fe9b4fb5fea99ef6 to your computer and use it in GitHub Desktop.
function Check-Help {
[CmdletBinding()]
param (
$Command
)
$CommandExists = $false
Try {
Get-Command $Command -ErrorAction Stop
$CommandExists = $true
} catch [System.Management.Automation.CommandNotFoundException] {
#Command doesn't exist...
}
if ($CommandExists) {
try {
Get-Help $Command -Online
} catch [System.Management.Automation.PSInvalidOperationException] {
Get-Help $Command -Full
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment