zoukankan      html  css  js  c++  java
  • 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:Usersclusource eposGitHubChuckLuScriptsPowershellchuck.ps1'. You can use the Update-ScriptFileInfo with -Force or New-ScriptFileInfo cmdlet to add the PSScriptInfo to the script file.
    At C:program filespowershell6-previewModulesPowerShellGetPSModule.psm1:10727 char:29
    + $PSScriptInfo = Test-ScriptFileInfo -Path $scriptFilePath
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (C:Usersclusourceu2026owershellchuck.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 FilesPowerShellModulesPowerShellGet2.1.2PSModule.psm1:10952 char:17
    + ... Publish-PSArtifactUtility @PublishPSArtifactUtility_Param ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : FailedToPublishTheScript,Publish-PSArtifactUtility

  • 相关阅读:
    javascript实现动态侧边栏
    javascript实现图片滚动
    C语言-----野指针
    守护进程daemon.c
    UDP网络程序设计
    TCP网络程序设计
    网络编程模型
    fork和vfork
    网络协议分析
    多线程同步
  • 原文地址:https://www.cnblogs.com/chucklu/p/10535169.html
Copyright © 2011-2022 走看看