PowerShell Gallery
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的更多相关文章
- 发布支持多线程的PowerShell模块 —— MultiThreadTaskRunner
应用场景 多线程在需要批量处理一些任务的时候相当有用,也更加有利于充分利用现有计算机的能力.所有主流的开发语言都支持多线程. 默认情况下,PowerShell作为一个脚本语言,是不支持多线程操作的,虽 ...
- PowerShell 操作 Azure Blob Storage
本文假设已经存在了一个 Azure Storage Account,需要进行文件的上传,下载,复制,删除等操作.为了方便查看 PowerShell 代码执行的结果,本文使用了 MS 发布的一个 Azu ...
- 支持国内版Office 365的PowerShell模块现已发布
作者:陈希章 发表于2017年5月12日 上一篇文章我详细介绍了如何在PowerShell中访问到Office 365的Graph API,在文章结尾处我留了一个问题,希望有朋友可以根据那个思路,尝试 ...
- 新版Azure Automation Account 浅析(二) --- 更新Powershell模块和创建Runbook
前篇我们讲了怎样创建一个自动化账户以及创建时候"Run As Account"选项背后的奥秘.这一篇针对在Azure自动化账户中使用Powershell Runbook的用户讲一下 ...
- powershell脚本的格式化
Auto Formatting PowerShell in Visual Studio Code 1.安装visual studio code 2.安装powershell extension 3.打 ...
- 黑科技抢先尝(续2) - Windows terminal中Powershell Tab的极简美化指南
目录 安装python 安装git 安装powerline字体 主题定制 安装oh-my-posh 查看策略组的执行权限 使用choco 安装终端模拟器 - ConEmu 优化 PowerShell ...
- Azure资源管理工具Azure PowerShell介绍
什么是 Azure PowerShell? Azure PowerShell 是一组模块,提供用于通过 Windows PowerShell 管理 Azure 的 cmdlet.你可以使用 cmdle ...
- ASP.NET Core 中文文档 第二章 指南(5) 在 Nano Server 上运行ASP.NET Core
原文 ASP.NET Core on Nano Server 作者 Sourabh Shirhatti 翻译 娄宇(Lyrics) 校对 刘怡(AlexLEWIS).许登洋(Seay).谢炀(kile ...
- PowerCLI
最近需要用命令行操作VMWare,现将一些经常用的命令记录一下.安装VMWare命令很简单,不再像原来需要单独下载PowerCLI安装包,直接在Powershell Gallery里在线安装即可. # ...
随机推荐
- fzu2204 dp
2015-10-06 19:31:05 n个有标号的球围成一个圈.每个球有两种颜色可以选择黑或白染色.问有多少种方案使得没有出现连续白球7个或连续黑球7个. 每组包含n,表示球的个数.(1 <= ...
- Spring源码阅读(二)
我们先看AbstractBeanFactory.getBean方法,这个方法通过bean名称类型等信息获取类实例,如果实例不存在则生产并缓存. //-------------------------- ...
- mybatis源码解析9---执行器Executor解析
从前面分析我们知道了sql的具体执行是通过调用SqlSession接口的对应的方法去执行的,而SqlSession最终都是通过调用了自己的Executor对象的query和update去执行的.本文就 ...
- JAVA基础3---运算符大全
Java中的运算符有以下种类:算术运算符.关系运算符.位运算符.逻辑运算符.赋值运算符.其他的运算符 现在假设定义 int A = 10,B = 5: 一.算术运算符 运算符 描述 案例 + 等同于数 ...
- ClassOne__HomeWork
1,static类型 static类型定义有两类,一类是静态数据,另一类是静态函数. 静态数据跟成员变量不同,它可以通过类名直接访问,而不需要通过定义对象来访问.它的的生成也和成员变量不一样,它只生成 ...
- FCoin优势
FCoin优势 顶级技术金融级别的速度和稳定,交易高效有保障:国际顶尖团队自主研发撮合系统,能够每秒处理200万笔交易:证券级先进算法,支持GTT.GTC.FOK.IOC等多种专业交易指令,为交易者提 ...
- 浅析PAC,修改PAC文件及user-rule文件实现自动代理
浅析PAC,修改PAC文件及user-rule文件实现自动代理 代理自动配置(英语:Proxy auto-config,简称PAC)是一种网页浏览器技术,用于定义浏览器该如何自动选择适当的代理服务器来 ...
- highchart应用示例1--2个不同类型变量2个y轴
1.ajax调用接口和处理数据 function getCityData() { var date1 = $('#datetimepicker1').val(); var date2 = $('#da ...
- Django框架----logging配置
我写Django项目常用的logging配置.(追加在setting.py文件中) LOGGING = { 'version': 1, 'disable_existing_loggers': Fals ...
- Google翻译实现
https://blog.csdn.net/yingshukun/article/details/53470424 Google翻译实现