Skip to content

Enhance standalone script installation #13883

Open

Description

@iRon7

Issue

I have a script which I would like to be able to directly install using the Install-Script from a (PowerShell Gallery) repository. The way it was setup is to download the script and dot-source the script.
As recommended by Michael Klement (@mklement0), I should actually create *.ps1 file instead of embedded script.

My current script looks like:

<#PSScriptInfo
.VERSION 3.3.6
.GUID 5f167621-6abe-4153-a26c-f643e1716720
.AUTHOR Ronald Bode (iRon)
.DESCRIPTION Stringifys an object to a PowerShell expression (PSON,  PowerShell Object Notation).
.COMPANYNAME
.COPYRIGHT
.TAGS PSON PowerShell Object Notation Expression Serialize Stringify
.LICENSE https://github.com/iRon7/ConvertTo-Expression/LICENSE.txt
.PROJECTURI https://github.com/iRon7/ConvertTo-Expression
.ICON https://raw.githubusercontent.com/iRon7/ConvertTo-Expression/master/ConvertTo-Expression.png
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
.PRIVATEDATA
#>
function ConvertTo-Expression {
    [CmdletBinding()][OutputType([scriptblock])] param()
    begin {}
    process {}
}; Set-Alias ctex ConvertTo-Expression

If I change the current script to just a *.ps1 script (preserving the metadata and only the inner script body), I will lose the alias (Set-Alias ctex ConvertTo-Expression).
Also noted by Michael Klement (@mklement0): another problem with using *.ps1 files directly as commands is that on case-sensitive file-systems - notably on Linux by default - you'll only be able to invoke the script if you match the file name's case exactly - which is both inconvenient and unexpected.
And I noticed that I do not see information like Version in the Get-Command ConvertTo-Expression (although it is shown in the Get-InstalledScript ConvertTo-Expression)

Summary of the new feature/enhancement

  • Automatically build a manifest from the script's metadata required for publishing
  • Add aliases information to new-scriptfileinfo/new-scriptfileinfo cmdlets
  • Possibly let the Install-Script cmdlet automatically transform a script into a simplified module using its metadata of the script
    I see no reason why the the manual steps provided in How to Write a PowerShell Script Module couldn't be automated (all mandatory steps are straight forward and optional configuration data is already available in the metadata)

Activity

  1. added
    Issue-Enhancement
    on Oct 26, 2020
  2. iSazonov commented on Oct 27, 2020

    @iSazonov
    Collaborator

    We discussed previously adding version info in scripts and this was rejected in favor of modules. I think any suggestions for adding meta information to script files will be rejected in favor of modules.

    I believe we have a better chance of moving forward if we consider a single file modules.

  3. added
    WG-Language
    on Oct 27, 2020
  4. added
    Resolution-No Activity
    on Nov 16, 2023
  5. iRon7 commented on Nov 16, 2023

    @iRon7
    Author

    Please either mark this issue with something like Resolution-Declined or put it on a kind of wishlist "Issue we would like to prioritize, but we can't commit we will get to it yet

  6. removed
    Resolution-No Activity
    on Nov 16, 2023
  7. added
    Resolution-No Activity
    on May 14, 2024
  8. iRon7 commented on May 15, 2024

    @iRon7
    Author

    Please either mark this issue with something like Resolution-Declined or put it on a kind of wishlist "Issue we would like to prioritize, but we can't commit we will get to it yet

  9. removed
    Resolution-No Activity
    on May 15, 2024
  10. added
    Resolution-No Activity
    on Nov 11, 2024
  11. iRon7 commented on Nov 11, 2024

    @iRon7
    Author

    Please either mark this issue with something like Resolution-Declined or put it on a kind of wishlist "Issue we would like to prioritize, but we can't commit we will get to it yet

    For the Alias part, it would probably make more sense to use the [Alias] type rather than the Set-Alias cmdlet

    As an aside: standalone scripts can also not be referenced in a Using statement. see: How to set script prerequisites

  12. removed
    Resolution-No Activity
    on Nov 11, 2024
  13. added
    Resolution-No Activity
    on May 10, 2025
  14. iRon7 commented on May 11, 2025

    @iRon7
    Author

    Please either mark this issue with something like Resolution-Declined or put it on a kind of wishlist "Issue we would like to prioritize, but we can't commit we will get to it yet

    For the Alias part, it would probably make more sense to use the [Alias] type rather than the Set-Alias cmdlet

    As an aside: standalone scripts can also not be referenced in a Using statement. see: How to set script prerequisites

  15. removed
    Resolution-No Activity
    on May 11, 2025
  16. added
    Resolution-No Activity
    and removed
    Resolution-No Activity
    on Nov 7, 2025
  17. added
    Resolution-No Activity
    on May 16, 2026
  18. iRon7 commented on May 16, 2026

    @iRon7
    Author

    Please triage/tag the issue accordingly to either close or Keep-Open to prevent the microsoft-github-policy-service.

  19. removed
    Resolution-No Activity
    on May 16, 2026
  20. added
    Resolution-No Activity
    on Nov 12, 2026
  21. microsoft-github-policy-service commented on Nov 12, 2026

    @microsoft-github-policy-service
    Contributor

    This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically.

    Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original.

  22. iRon7 commented on Nov 13, 2026

    @iRon7
    Author

    Please triage/tag the issue accordingly to either close or Keep-Open to prevent the microsoft-github-policy-service.

  23. removed
    Resolution-No Activity
    on Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-EnhancementWG-Language

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions