https://docs.microsoft.com/en-us/powershell/gallery/getting-started

https://www.powershellgallery.com/packages?q=PowerShell-Beautifier

Get-PSRepository

Name InstallationPolicy SourceLocation
---- ------------------ --------------
PSGallery Untrusted https://www.powershellgallery.com/api/v2

注册完账号,在publish页面看到提示

自己的Powershell脚本应该只算是script

https://docs.microsoft.com/en-us/powershell/module/powershellget/publish-script?view=powershell-6

API keys


An API key is a token that can identify you to PowerShell Gallery. To publish a package to the PowerShell Gallery, run the
Publish-Module or Publish-Script cmdlet, and specify
your personal API key as the value of the NuGetApiKey parameter.

Always keep your API keys a secret! If one of your keys is accidentally revealed泄露,
you can always generate a new one at any time. You can also remove existing API keys if necessary.

Note: To install packages from https://www.powershellgallery.com requires the latest version of PowerShellGet module.

错误处理

直接publish script,提示错误

http://www.brianbunke.com/blog/2017/01/09/publishing-scripts/

Publish-Script -Path .\chuck.ps1 -NuGetApiKey mykey

Test-ScriptFileInfo : PSScriptInfo is not specified in the script file 'C:\Users\clu\source\repos\GitHub\ChuckLu\Scripts\Powershell\chuck.ps1'. You can use the Update-ScriptFileInfo with -Force or New-ScriptFileInfo cmdlet to add the PSScriptInfo to the script file.
At C:\program files\powershell\6-preview\Modules\PowerShellGet\PSModule.psm1:10727 char:29
+ $PSScriptInfo = Test-ScriptFileInfo -Path $scriptFilePath
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (C:\Users\clu\source\u2026owershell\chuck.ps1:String) [Test-ScriptFileInfo], ArgumentException
+ FullyQualifiedErrorId : MissingPSScriptInfo,Test-ScriptFileInfo

需要https://docs.microsoft.com/en-us/powershell/module/powershellget/new-scriptfileinfo?view=powershell-6

发现New-ScriptFileInfo无法对现有文件操作,改用Update-ScriptFileInfo。还需要加上force参数

Update-ScriptFileInfo .\chuck.ps1 -Author "chuck.lu@qq.com" -Description "Chuck's scripts" -Force -Verbose

发布超时

Publish-PSArtifactUtility : Failed to publish script 'chuck': 'info : Pushing chuck.1.0.0.nupkg to 'https://www.powershellgallery.com/api/v2/package/'...
info : PUT https://www.powershellgallery.com/api/v2/package/
info : An error was encountered when fetching 'PUT https://www.powershellgallery.com/api/v2/package/'. The request will now be retried.
info : An error occurred while sending the request.
info : The server returned an invalid or unrecognized response.
info : PUT https://www.powershellgallery.com/api/v2/package/
info : An error was encountered when fetching 'PUT https://www.powershellgallery.com/api/v2/package/'. The request will now be retried.
info : An error occurred while sending the request.
info : The server returned an invalid or unrecognized response.
info : PUT https://www.powershellgallery.com/api/v2/package/
error: The operation was canceled.
error: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
error: The I/O operation has been aborted because of either a thread exit or an application request.
error: Pushing took too long. You can change the default timeout of 300 seconds by using the --timeout <seconds> option with the push command.
'.
At C:\Program Files\PowerShell\Modules\PowerShellGet\2.1.2\PSModule.psm1:10952 char:17
+ ... Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : FailedToPublishTheScript,Publish-PSArtifactUtility

PowerShell Gallery的更多相关文章

  1. 发布支持多线程的PowerShell模块 —— MultiThreadTaskRunner

    应用场景 多线程在需要批量处理一些任务的时候相当有用,也更加有利于充分利用现有计算机的能力.所有主流的开发语言都支持多线程. 默认情况下,PowerShell作为一个脚本语言,是不支持多线程操作的,虽 ...

  2. PowerShell 操作 Azure Blob Storage

    本文假设已经存在了一个 Azure Storage Account,需要进行文件的上传,下载,复制,删除等操作.为了方便查看 PowerShell 代码执行的结果,本文使用了 MS 发布的一个 Azu ...

  3. 支持国内版Office 365的PowerShell模块现已发布

    作者:陈希章 发表于2017年5月12日 上一篇文章我详细介绍了如何在PowerShell中访问到Office 365的Graph API,在文章结尾处我留了一个问题,希望有朋友可以根据那个思路,尝试 ...

  4. 新版Azure Automation Account 浅析(二) --- 更新Powershell模块和创建Runbook

    前篇我们讲了怎样创建一个自动化账户以及创建时候"Run As Account"选项背后的奥秘.这一篇针对在Azure自动化账户中使用Powershell Runbook的用户讲一下 ...

  5. powershell脚本的格式化

    Auto Formatting PowerShell in Visual Studio Code 1.安装visual studio code 2.安装powershell extension 3.打 ...

  6. 黑科技抢先尝(续2) - Windows terminal中Powershell Tab的极简美化指南

    目录 安装python 安装git 安装powerline字体 主题定制 安装oh-my-posh 查看策略组的执行权限 使用choco 安装终端模拟器 - ConEmu 优化 PowerShell ...

  7. Azure资源管理工具Azure PowerShell介绍

    什么是 Azure PowerShell? Azure PowerShell 是一组模块,提供用于通过 Windows PowerShell 管理 Azure 的 cmdlet.你可以使用 cmdle ...

  8. ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core

    原文 ASP.NET Core on Nano Server 作者 Sourabh Shirhatti 翻译 娄宇(Lyrics) 校对 刘怡(AlexLEWIS).许登洋(Seay).谢炀(kile ...

  9. PowerCLI

    最近需要用命令行操作VMWare,现将一些经常用的命令记录一下.安装VMWare命令很简单,不再像原来需要单独下载PowerCLI安装包,直接在Powershell Gallery里在线安装即可. # ...

随机推荐

  1. linux文本文件编辑命令

    1.cat命令 cat命令用于查看纯文本文件(内容较少的),格式为“cat [选项] [文件]”. Linux系统中有多个用于查看文本内容的命令,每个命令都有自己的特点,比如这个cat命令就是用于查看 ...

  2. 大话设计模式C++ 备忘录模式

    备忘录(Memento):在不破坏封装性的前提下,捕获一个对象的内部状态,并在该对象之外保存这个状态.这样以后就可将对象恢复到原先保存的状态. 角色: (1)Originator(发起人):创建盒子, ...

  3. 模拟QQ登录

    2018-10-28 15:54:38 开始写 import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.bor ...

  4. uvalive 4848 Tour Belt

    题意: 一个KTO被定义为一个特殊的连通块,这个连通块满足一个要求,这个连通块中的最短的边大于 与这个连通相连的不属于这个连通块的边中的最大值. 给出一个图,统计KTO里面的点有多少个.(一个点可以属 ...

  5. 爬虫万金油,一鹅在手,抓遍全球:goose 简介!

    GOOSE 现已弃用 经过多年的服务,GOOSE接口和支持它的MySQL数据现已弃用 . 在我们进行替换的同时,我们建议寻找一般查询功能的用户在http://rdf.geneontology.org上 ...

  6. 20165305 苏振龙《Java程序设计》第九周学习总结

    第十三章 Java网络编程 学习了解用于网络编程的类,了解URL.Socket.InetAddress和DatagramSocket类在网络编程中的重要作用 使用URL创建对象的应用程序称作客户端程序 ...

  7. 【函数封装】javascript判断移动端操作系统为android 或 ios 或 iphoneX

    function isPhone(){ var u = navigator.userAgent, app = navigator.appVersion; var isAndroid = u.index ...

  8. Codeforce 513A - Game

    Two players play a simple game. Each player is provided with a box with balls. First player's box co ...

  9. Python之pytest 基础

    pytest是一个非常成熟的全功能的Python测试框架,主要特点有以下几点:1.简单灵活,容易上手:2.支持参数化:3.能够支持简单的单元测试和复杂的功能测试,还可以用来做selenium/appn ...

  10. CE教程

    https://www.52pojie.cn/thread-726510-1-1.htmlhttps://www.52pojie.cn/thread-726154-1-1.html https://w ...