Skip to content

Test-ScriptFileInfo fails when blank line removed from between comment blocks #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JeremyTBradshaw opened this issue Dec 2, 2020 · 0 comments
Labels
Area-InfoFile Issue-Bug Something isn't working

Comments

@JeremyTBradshaw
Copy link

JeremyTBradshaw commented Dec 2, 2020

This issue was once opened in another repository: PowerShell/PowerShell#11173

The issue is present in Windows PowerShell 5.1, and PowerShell 7*. When you've got a script file which has the PSCriptInfo comment block, usually added/updated with New-/Update-ScriptFileInfo, if you remove the blank line between this comment block and the next comment block where you include your usual keywords/sections, Test-ScriptFileInfo fails, and since both New-/Update-ScriptFileInfo use Test-ScriptFileInfo, they also fail.

Sample file that passes:

<#PSScriptInfo

    .VERSION 1.0.0
    .GUID 60e7a6d6-791b-48b7-be15-6e6a793f9812
    .AUTHOR Jeremy.Bradshaw@Outlook.com
    .TAGS Exchange Outlook EWS EWS Managed API Large Items Migration
    .LICENSEURI https://github.com/JeremyTBradshaw/PowerShell
    .PROJECTURI https://github.com/JeremyTBradshaw/PowerShell/blob/master/LICENSE
    .RELEASENOTES
#>

<#
    .Synopsis
    Find large items in mailbox(es) using EWS Managed API 2.2.

    .Description
    Find all 'large' items using the hidden 'AllItems' search folder.  This method is much faster than enumerating
    folders and items to accomplish the same thing (faster as in hours, even days, depending on the number and size of
    mailboxes being searched).
    ...
    ...
#>

Same file, but with the empty line removed, which fails:

<#PSScriptInfo

    .VERSION 1.0.0
    .GUID 60e7a6d6-791b-48b7-be15-6e6a793f9812
    .AUTHOR Jeremy.Bradshaw@Outlook.com
    .TAGS Exchange Outlook EWS EWS Managed API Large Items Migration
    .LICENSEURI https://github.com/JeremyTBradshaw/PowerShell
    .PROJECTURI https://github.com/JeremyTBradshaw/PowerShell/blob/master/LICENSE
    .RELEASENOTES
#>
<#
    .Synopsis
    Find large items in mailbox(es) using EWS Managed API 2.2.

    .Description
    Find all 'large' items using the hidden 'AllItems' search folder.  This method is much faster than enumerating
    folders and items to accomplish the same thing (faster as in hours, even days, depending on the number and size of
    mailboxes being searched).
    ...
    ...
#>

Error:

PS C:\Users\JB> Test-ScriptFileInfo -Path .\Desktop\Get-MailboxLargeItems.ps1
Test-ScriptFileInfo: Script 'C:\Users\JB\Desktop\Get-MailboxLargeItems.ps1' is missing required metadata properties. Verify that the script file has Version, Guid, Description and Author properties. You can use the Update-ScriptFileInfo or New-ScriptFileInfo cmdlet to add or update the PSScriptInfo to the script file.

PowerShellGet version info:

PS C:\Users\JB> Get-Module powershellget | fl

Name              : PowerShellGet
Path              : C:\Users\JB\Documents\PowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1
Description       : PowerShell module with commands for discovering, installing, updating and publishing the PowerShell
                    artifacts like Modules, DSC Resources, Role Capabilities and Scripts.
ModuleType        : Script
Version           : 2.2.5
PreRelease        :
NestedModules     : {}
ExportedFunctions : {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability…}
ExportedCmdlets   :
ExportedVariables : PSGetPath
ExportedAliases   : {fimo, inmo, pumo, upmo}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-InfoFile Issue-Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants