Skip to content

New/Update-PSScriptFileInfo adds required module #requires statement with -Module parameter #1558

Open
@peetrike

Description

@peetrike

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

When creating or modifying script metadata with New-PSScriptFileInfo or Update-PSScriptFileInfo, the #requires statement is added as following:

#Requires -Module ActiveDirectory

According to About Requires document, it should be:

#Requires -Modules ActiveDirectory

It seems, that PowerShell does not care, when executing script, but for example VS Code syntax coloring does not recognize the statement any more.

Expected behavior

PS > New-PSScriptFileInfo -Path .\newscript.ps1 -Description 'problem adding module dependency' -RequiredModules @{ModuleName = 'SqlServer' } -ExternalModuleDependencies sqlserver

PS > Get-Content -Path .\newscript.ps1 | select-string '#Requires'

#Requires -Modules ActiveDirectory

Actual behavior

PS > Update-PSScriptFileInfo -Path .\newscript.ps1 -Description 'problem adding module dependency' -RequiredModules @{ModuleName = 'SqlServer' } -ExternalModuleDependencies sqlserver

PS > Get-Content -Path .\newscript.ps1 | select-string '#Requires'

#Requires -Module ActiveDirectory

Error details

It's not an error per se, as PowerShell seems to apply the usual cmdlet parameter shortening rules here. But it differs from documentation and confuses syntax coloring in VS Code. Even GitHub syntax coloring is confused

Environment data

Versions
--------
PSResourceGet: 1.0.1
PowerShell: 7.4.1 or 5.1

Visuals

No response

Metadata

Metadata

Assignees

Type

No type

Projects

Status

TODO

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions