• 解决powershell7.1的Get-Help找不到对应的详细帮助


      参考资料:

      https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/update-help?view=powershell-7.1

      最近工作学习环境从macos转到了windows。macos上有zsh和bash,windows上有cmd和powershell。powershell显然更加现代,所以想熟悉熟悉它的使用。寻求解决方法的盆友直接看分割线后的文字。

      powershell最常见的命令被称为cmdlet,但是当我在使用help(or Get-Help or man) xxCmdlet的时候,输出的东西让我很迷惑。会有下面的报错(因为问题我已经解决了,所以只能记录个大概):

      上面的截图是我在一本书里面找的,不过如果你用的是最新的7.1(or 7.2)输出的文字应该都是英文。比如最后面的备注应该像下面这样:

    Get-Help cannot find the Help files for this cmdlet on this computer. It is is displaying only partial help.
            -- To download and install Help files for the module that includes
        this cmdlet, use Update-Help.
            -- To view the Help topic for this cmdlet online, type: "Get-Help
        xxxxx -Online" or
               go to http://go.microsoft.com/fwlink/?LinkID=xxxx.
    

      奇了怪了,为什么这个帮助文档这么鸡肋?没有一个例子,没有一句人话,只有用法和输入输出?

      不过细读了上面这一段警告,我们得出了答案:原来是帮助文档没有被下载下来!

      那么我们就乖乖听话,使用Update-Help命令将文档下载下来吧!赶快运行~

      可是,因为俺们是中国人,OS的默认语言就是zh-CN。所以在使用Update-Help的时候会报一个错说找不到某某module的中文文档。这不要紧,只要大部分的都下下来了不就行了吗?

      可是,事与愿违,下载下来之后再次运行Get-Help。那个提示还是崩了出来,弹出来的还是残缺的帮助文档!


      多方查找后我认为,目前因为pwsh的版本太高,没有推出zh-CN的文档,所以我们下载的都是英文文档。但是,pwsh在查找文档的时候又会主动去找zh-CN的文档,所以就找不到!找了doc后我发现了解决方法:

    Update-Help -UICulture en-US
    

      使用上面的命令,保证了将更新的帮助文档弄成en-US。之后再运行Get-Help,就正常啦!放一个示例:

    NAME
        Get-Command
    
    SYNOPSIS
        Gets all commands.
    
    
    SYNTAX
        Get-Command [[-Name] <System.String[]>] [[-ArgumentList] <System.Object[]>] [-All] [-C
        ommandType {Alias | Function | Filter | Cmdlet | ExternalScript | Application | Script
         | Workflow | Configuration | All}] [-FullyQualifiedModule <Microsoft.PowerShell.Comma
        nds.ModuleSpecification[]>] [-ListImported] [-Module <System.String[]>] [-ParameterNam
        e <System.String[]>] [-ParameterType <System.Management.Automation.PSTypeName[]>] [-Sh
        owCommandInfo] [-Syntax] [-TotalCount <System.Int32>] [-UseAbbreviationExpansion] [-Us
        eFuzzyMatching] [<CommonParameters>]
    
        Get-Command [[-ArgumentList] <System.Object[]>] [-All] [-FullyQualifiedModule <Microso
        ft.PowerShell.Commands.ModuleSpecification[]>] [-ListImported] [-Module <System.String
        []>] [-Noun <System.String[]>] [-ParameterName <System.String[]>] [-ParameterType <Sys
        tem.Management.Automation.PSTypeName[]>] [-ShowCommandInfo] [-Syntax] [-TotalCount <Sy
        stem.Int32>] [-Verb <System.String[]>] [<CommonParameters>]
    
    
    DESCRIPTION
        The `Get-Command` cmdlet gets all commands that are installed on the computer, includi
        ng cmdlets, aliases, functions, filters, scripts, and applications. `Get-Command` gets
         the commands from PowerShell modules and commands that were imported from other sessi
        ons. To get only commands that have been imported into the current session, use the Li
        stImported parameter.
    
        Without parameters, `Get-Command` gets all of the cmdlets, functions, and aliases inst
        alled on the computer. `Get-Command *` gets all types of commands, including all of th
        e non-PowerShell files in the Path environment variable (`$env:Path`), which it lists
        in the Application command type.
    
        `Get-Command` that uses the exact name of the command, without wildcard characters, au
        tomatically imports the module that contains the command so that you can use the comma
        nd immediately. To enable, disable, and configure automatic importing of modules, use
        the `$PSModuleAutoLoadingPreference` preference variable. For more information, see ab
        out_Preference_Variables (About/about_Preference_Variables.md).
    
        `Get-Command` gets its data directly from the command code, unlike `Get-Help`, which g
        ets its information from help topics.
    
        Starting in Windows PowerShell 5.0, results of the `Get-Command` cmdlet display a Vers
        ion column by default. A new Version property has been added to the CommandInfo class.
    
    
    RELATED LINKS
        Online Version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core
        /get-command?view=powershell-7.1&WT.mc_id=ps-gethelp
        Export-PSSession
        Get-Help
        Get-Member
        Get-PSDrive
        Import-PSSession
        about_Command_Precedence
    
    REMARKS
        To see the examples, type: "Get-Help Get-Command -Examples"
        For more information, type: "Get-Help Get-Command -Detailed"
        For technical information, type: "Get-Help Get-Command -Full"
        For online help, type: "Get-Help Get-Command -Online"
    

      可见警告的消息不见了!可以用Get-Help Get-Command -Examples等命令获取更为详细的帮助了!

  • 相关阅读:
    android activity的生命周期和启动模式
    Android ListView的基本应用
    android WebView技术笔记(存储技术)
    Android RecyclerView初探
    Android-----ListView组件使用(实现点击选择)
    Android-----CheckBox复选使用(实现简单选餐)
    Android-----RadioButton单选使用(实现简单温度转换)
    Android-----Intent通过startActivityForResult(Intent intent , int 标志符)启动新的Activity
    Android-----Intent中通过startActivity(Intent intent )显式启动新的Activity
    Android-----Intent中通过startActivity(Intent intent )隐式启动新的Activity
  • 原文地址:https://www.cnblogs.com/chester-cs/p/14034967.html
Copyright © 2020-2023  润新知