当前位置: 首页 > news >正文

powershell@update-help更新文档和离线文档安装@并行加速安装帮助文档更新@安装报错问题

文章目录

    • powershell update-help
      • 为所有可用模块更新文档
      • 为指定模块更新帮助文档
    • 保存文档到本地(save-help)
      • 使用并行下载策略
      • 分享给其他设备安装

powershell update-help

  • Update-Help (Microsoft.PowerShell.Core) - PowerShell | Microsoft Learn

  • 虽然powershell会为cmdlet或者用户自定义的powershell函数生成文档,但是基本上仅限于函数参数的类型和属性信息,对于参数的直观描述往往是缺乏的,而且无法生成,例如ls -path这里的-Path参数的帮助文档

    • -Path <System.String[]>Specifies a path to one or more locations. Wildcards are accepted. The default location is the current directory (`.`).Required?                    falsePosition?                    0Default value                Current directoryAccept pipeline input?       True (ByPropertyName, ByValue)Accept wildcard characters?  true
      
    • 如果没有安装相应文档,那么中间的一段描述 Specifies a path to one or more locations. Wildcards are accepted. The default location is the current directory (.).就没有

  • 在powershell中直接使用update-help可能会失败,特别是非英文系统

  • 建议使用必要的参数来更新powershell的帮助文档,或者使用离线的方式更新或着安装文档,尤其是多台设备共享

为所有可用模块更新文档

  • 英文文档一定存在,所以报错机率比较小
  • 使用verbose参数来查看安装进度,及早发现问题
 update-help -Verbose -UICulture en-US

为指定模块更新帮助文档

  • 比如我们为模块Microsoft.Powershell.Management更新文档

  • PS🌙[BAT:99%][MEM:63.5% (4.99/7.85)GB][1:10:04]
    # [cxxu@CXXUREDMIBOOK][<W:192.168.1.46>][~]
    PS> update-help -Module Microsoft.PowerShell.Management -Verbose
    VERBOSE: Resolving URI: "https://aka.ms/powershell73-help"
    VERBOSE: Your connection has been redirected to the following URI: "https://pshelpprod.blob.core.windows.net/cabinets/powershell-7.3/"
    VERBOSE: Postponing error and trying fallback cultures, will show as error if none of fallbacks are supported:
    The specified culture is not supported: zh-CN. Specify a culture from the following list: {en-US}.
    VERBOSE: Resolving URI: "https://aka.ms/powershell73-help"
    VERBOSE: Your connection has been redirected to the following URI:
    ....Update-Help: Failed to update Help for the module(s) 'Microsoft.PowerShell.Management' with UI culture(s) {zh-CN} : The specified culture is not supported: zh-CN. Specify a culture from the following list: {en-US}..
    English-US help content is available and can be installed using: Update-Help -UICulture en-US.PS🌙[BAT:99%][MEM:62.73% (4.92/7.85)GB][1:11:03]
    # [cxxu@CXXUREDMIBOOK][<W:192.168.1.46>][~]
    PS> update-help -UICulture en-US -Verbose -Module Microsoft.Powershell.Management
    VERBOSE: Resolving URI: "https://aka.ms/powershell73-help"
    VERBOSE: Your connection has been redirected to the following URI: "https://pshelpprod.blob.core.windows.net/cabinets/powershell-7.3/"
    VERBOSE: Performing the operation "Update-Help" on target "Microsoft.PowerShell.Management, Current Version: 0.0.0.0, Available Version: 7.3.0.0, UICulture: en-US".
    VERBOSE: Microsoft.PowerShell.Management: Updated C:\Users\cxxu\Documents\PowerShell\Help\en-US\Microsoft.PowerShell.Commands.Management.dll-Help.xml. Culture en-US Version 7.3.0.0
    

保存文档到本地(save-help)

Save-Help (Microsoft.PowerShell.Core) - PowerShell | Microsoft Learn

你需要指定一个存在的目录作为Save-Help的参数,否则无法保存

PS🌙[BAT:99%][MEM:53.45% (4.2/7.85)GB][1:30:55]
# [cxxu@CXXUREDMIBOOK][<W:192.168.1.46>][~\Desktop]
PS> Save-Help  -Verbose -UICulture en-US -DestinationPath C:\Share\VERBOSE: Resolving URI: "https://aka.ms/powershell73-help"
VERBOSE: Your connection has been redirected to the following URI: "https://pshelpprod.blob.core.windows.net/cabinets/powershell-7.3/"
VERBOSE: CimCmdlets: Saved C:\Share\CimCmdlets_fb6cc51d-c096-4b38-b78d-0fed6277096a_en-US_HelpContent.cab. Culture en-US Version 7.3.0.0
VERBOSE: Resolving URI: "https://aka.ms/powershell73-help"
VERBOSE: Your connection has been redirected to the following URI: 
...
VERBOSE: Your connection has been redirected to the following URI: "https://pshelpprod.blob.core.windows.net/cabinets/powershell-7.3/"
VERBOSE: Microsoft.PowerShell.Core: Saved C:\Share\Microsoft.PowerShell.Core_00000000-0000-0000-0000-000000000000_en-US_HelpContent.cab. Culture en-US Version 7.3.0.0PS🌙[BAT:99%][MEM:33.57% (2.64/7.85)GB][1:34:18]
# [cxxu@CXXUREDMIBOOK][<W:192.168.1.46>][~\Desktop]

安装了快5分钟才结束,总体积大约2~3MB

使用并行下载策略

$modules = Get-Module -ListAvailable | Where-Object -Property HelpInfoUri$Destination = 'C:\PsHelpx' #指定你想要的下载目录即可
New-Item -ItemType Directory -Path $Destination -Verbose -Force$modules.Name | ForEach-Object -Parallel {# param($Destination)$Destination = $using:Destination#这里可以指定verbose观察输出,也可以不使用-Verbose详情,检查下载目录即可Save-Help -Verbose -Module $_ -DestinationPath $Destination -UICulture en-us -ErrorAction SilentlyContinue
} -ThrottleLimit 64 

耗时在10秒内

也可以用并发的方式在线安装

$modules = Get-Module -ListAvailable | Where-Object -Property HelpInfoUri$modules.Name | ForEach-Object -Parallel {#这里可以指定verbose观察输出,也可以不使用-Verbose详情,检查下载目录即可update-help -Verbose -Module $_  -UICulture en-us # -ErrorAction SilentlyContinue
} -ThrottleLimit 64 

分享给其他设备安装

  • 局域网内可以使用smb等工具分享,也可以配合robocopy传输内容给对方

  • 对方接受后执行update-help命令安装(注意仍然要指定-UICulture en-us),部分模块的文档会安装失败,这种情况下需要手动补充安装

相关文章:

  • 【LeetCode:219. 存在重复元素 II + 哈希表】
  • Ant design vue中的提示框(a-tooltip)
  • Linux应用开发实验班——JSON-RPC
  • 大数据新视界 --大数据大厂之HBase 在大数据存储中的应用与表结构设计
  • 【有啥问啥】“弱激励学习(Weak Incentive Learning)”的原理与过程解析
  • 如何使用ssm实现基于SpringMVC网上选课系统的设计与实现
  • 努比亚z17努比亚NX563j原厂固件卡刷包下载_刷机ROM固件包下载-原厂ROM固件-安卓刷机固件网
  • Python图形用户界面设计的15个基础组件
  • 代码编码规范文档(参考)
  • GPT实现联网,NextChat插件的配置说明
  • 理解和使用语言模型的监督微调 (SFT)
  • 贷款并非只看利息低,还有很多你知不道的地方
  • 探索未来IT技术的浩瀚星河:一场跨越时代的数字盛宴
  • 沉浸式艺术创作:FLUX.1模型下的Java开发者体验之旅
  • python基础之绘图turtle与分词
  • __proto__ 和 prototype的关系
  • Angular数据绑定机制
  • - C#编程大幅提高OUTLOOK的邮件搜索能力!
  • Iterator 和 for...of 循环
  • Java基本数据类型之Number
  • leetcode-27. Remove Element
  • leetcode98. Validate Binary Search Tree
  • SwizzleMethod 黑魔法
  • ViewService——一种保证客户端与服务端同步的方法
  • vuex 学习笔记 01
  • vue从创建到完整的饿了么(11)组件的使用(svg图标及watch的简单使用)
  • 官方新出的 Kotlin 扩展库 KTX,到底帮你干了什么?
  • 机器学习中为什么要做归一化normalization
  • 悄悄地说一个bug
  • 如何使用 JavaScript 解析 URL
  • 我这样减少了26.5M Java内存!
  • 如何通过报表单元格右键控制报表跳转到不同链接地址 ...
  • ​LeetCode解法汇总2808. 使循环数组所有元素相等的最少秒数
  • ​草莓熊python turtle绘图代码(玫瑰花版)附源代码
  • # 消息中间件 RocketMQ 高级功能和源码分析(七)
  • #我与Java虚拟机的故事#连载05:Java虚拟机的修炼之道
  • (c语言版)滑动窗口 给定一个字符串,只包含字母和数字,按要求找出字符串中的最长(连续)子串的长度
  • (MTK)java文件添加简单接口并配置相应的SELinux avc 权限笔记2
  • (创新)基于VMD-CNN-BiLSTM的电力负荷预测—代码+数据
  • (二十五)admin-boot项目之集成消息队列Rabbitmq
  • (附源码)小程序儿童艺术培训机构教育管理小程序 毕业设计 201740
  • (三)docker:Dockerfile构建容器运行jar包
  • (十一)JAVA springboot ssm b2b2c多用户商城系统源码:服务网关Zuul高级篇
  • (循环依赖问题)学习spring的第九天
  • (已解决)报错:Could not load the Qt platform plugin “xcb“
  • (转)Oracle 9i 数据库设计指引全集(1)
  • .babyk勒索病毒解析:恶意更新如何威胁您的数据安全
  • .gitignore
  • .NET Framework 3.5中序列化成JSON数据及JSON数据的反序列化,以及jQuery的调用JSON
  • .net生成的类,跨工程调用显示注释
  • .NET是什么
  • .vimrc php,修改home目录下的.vimrc文件,vim配置php高亮显示
  • @TableLogic注解说明,以及对增删改查的影响
  • [2016.7.test1] T2 偷天换日 [codevs 1163 访问艺术馆(类似)]
  • [20190401]关于semtimedop函数调用.txt