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. Some Useful Resources for the Future Usage

    并发编程 http://ifeve.com/ 美国各州 http://114.xixik.com/usa-stats/ 美国各州邮编zip code -> https://www.douban. ...

  2. field_automation源码分析

    field_automation主要通过uvm_field_utils_begin和uvm_field_utils_end来加到自己写的class中. uvm_field_utils_begin,在o ...

  3. 2.sklearn库中的标准数据集与基本功能

    sklearn库中的标准数据集与基本功能 下面我们详细介绍几个有代表性的数据集: 当然同学们也可以用sklearn机器学习函数来挖掘这些数据,看看可不可以捕捉到一些有趣的想象或者是发现: 波士顿房价数 ...

  4. Yii数据对象笔记

    要执行一个SQL查询,应该遵循以下步骤 - 创建一个 yii\db\Command 的 SQL查询命令 绑定参数(非必须) 执行命令 第1步 - 创建一个 actionTestDb()方法在 Site ...

  5. Game (思维)

    #include<bits/stdc++.h> using namespace std; ; char str[maxn][maxn]; int cntx[maxn], cnty[maxn ...

  6. 接口作为方法的参数或返回值——List接口

    接口作为方法的参数或返回值,源码可知,List为一个接口,ArraryList是的它的实现类: 其中,addNames方法中,入参和返回值都List接口,入参是多态的,编译看左,运行看右(访问成员方法 ...

  7. AtCoder Beginner Contest 085(ABCD)

    A - Already 2018 题目链接:https://abc085.contest.atcoder.jp/tasks/abc085_a Time limit : 2sec / Memory li ...

  8. Selenium 常用定位对象元素的方法

    常见定位对象元素的方法 在使用selenium webdriver进行元素定位时,通常使用findElement或findElements方法结合By类返回的元素句柄来定位元素.其中By类的常用定位方 ...

  9. ATM开学测试(未完成)

    package ATM_design; //信1705-2 20173456 张浩 import java.util.*; import java.io.File; import java.io.Fi ...

  10. 前端异步的一种方法库:axios

    关于axios,其实原本在做开发的几年里并不知道,一直使用的也都是jquery的ajax.后来因为一个同事的述说,我才知道有这么个库,基于promise的http库. 看来,以前的我确实比较井底之蛙了 ...