salut,
voici une petite fonction proxy du cmdlet Get-Help qui vous permettera d'avoir une aide graphique sans utilisation du paramètre "Online" (qui requiert une connexion internet)...la démarche est toute simple: On décompile à la volée le fichier d'aide local de PS puis on sélectionne la rubrique choisi par une simple recherche...
voici une petite fonction proxy du cmdlet Get-Help qui vous permettera d'avoir une aide graphique sans utilisation du paramètre "Online" (qui requiert une connexion internet)...la démarche est toute simple: On décompile à la volée le fichier d'aide local de PS puis on sélectionne la rubrique choisi par une simple recherche...
Function Get-Man {
<#
.ForwardHelpTargetName Get-Help
.ForwardHelpCategory Cmdlet
#>
[CmdletBinding(DefaultParameterSetName='AllUsersView')]
param(
[Parameter(Position=0, ValueFromPipelineByPropertyName=$true)]
[System.String]
${Name},
[System.String]
${Path},
[System.String[]]
${Category},
[System.String[]]
${Component},
[System.String[]]
${Functionality},
[System.String[]]
${Role},
[Parameter(ParameterSetName='DetailedView')]
[Switch]
${Detailed},
[Parameter(ParameterSetName='AllUsersView')]
[Switch]
${Full},
[Parameter(ParameterSetName='Examples')]
[Switch]
${Examples},
[Parameter(ParameterSetName='Parameters')]
[System.String]
${Parameter},
# affiche l'aide dans le navigateur par defaut
[Switch]
${ShowUI},
[Switch]
${Online})
begin
{
try {
$outBuffer = $null
if ($PSBoundParameters.TryGetValue('OutBuffer', [ref]$outBuffer))
{
$PSBoundParameters['OutBuffer'] = 1
}
$wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Get-Help', [System.Management.Automation.CommandTypes]::Cmdlet)
if($PSBoundParameters['ShowUI']) {
$null=$PSBoundParameters.Remove('ShowUI')
function invokeUI {
param(
[Parameter(ValueFromPipeLineByPropertyName=$True)]
$Name
)
Begin{
$HelpChm = "$env:Windir\Help\WindowsPowerShellHelp.chm"
$HelpTmp = "$env:Temp\PSCmd"
if (! (Test-Path $HelpChm) ) {
throw "le fichier source $HelpChm est introuvable"
}
if(! (Test-Path $HelpTmp)) {
Start-Process -File "hh.exe" -Arg "-decompile $HelpTmp $HelpChm" -Wait
}
$HtmlFiles = Get-childItem "$HelpTmp\html" *.htm
}
Process{
forEach($file in @($HtmlFiles)) {
[Xml]$Xml = get-content $file.Fullname
if($Xml.html.head.title -ieq "$Name") {
invoke-item $file.Fullname
}
}
}
End{
Remove-Item $HelpTmp -Recurse
}
}
$scriptCmd = {& $wrappedCmd @PSBoundParameters | invokeUI}
} else {
$scriptCmd = {& $wrappedCmd @PSBoundParameters }
}
$steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin)
$steppablePipeline.Begin($PSCmdlet)
} catch {
throw
}
}
process
{
try {
$steppablePipeline.Process($_)
} catch {
throw
}
}
end
{
try {
$steppablePipeline.End()
} catch {
throw
}
}
}
l'utilisation de Get-Man est simple voici quelques exemples:PS> Get-Man -Name Select-Xml -ShowUI
PS> Get-commend Get-Man -syntax
Aucun commentaire:
Enregistrer un commentaire