Test-ScriptFileInfo
Validates a comment block for a script.
Syntax
Test-ScriptFileInfo
[-Path] <String>
[<CommonParameters>]
Test-ScriptFileInfo
-LiteralPath <String>
[<CommonParameters>]
Description
The Test-ScriptFileInfo
cmdlet validates the comment block at the beginning of a script that will
be published with the Publish-Script cmdlet. If the comment block has an error, this cmdlet returns
information about where the error is located or how to correct it.
This is a proxy cmdlet for the Test-PSScriptFileInfo
cmdlet in the
Microsoft.PowerShell.PSResourceGet. For more information, see
Test-PSScriptFileInfo.
Examples
Example 1: Test a script file
Test-ScriptFileInfo -Path "C:\temp\temp_scripts\New-ScriptFile.ps1"
This command tests the New-ScriptFile.ps1 script file and displays the results. The script file includes valid metadata.
Example 2: Test a script file that has values for all metadata properties
Test-ScriptFileInfo -Path "D:\code\Test-Runbook.ps1" | Format-List *
Name : Test-Runbook
Path : D:\code\Test-Runbook.ps1
ScriptBase : D:\code
ReleaseNotes : {contoso script now supports following features, Feature 1, Feature 2, Feature 3...}
Version : 1.0
Guid : eb246b19-17da-4392-8c89-7c280f69ad0e
Author : pattif
CompanyName : Microsoft Corporation
Copyright : 2015 Microsoft Corporation. All rights reserved.
Tags : {Tag1, Tag2, Tag3}
LicenseUri : https://contoso.com/License
ProjectUri : https://contoso.com/
IconUri : https://contoso.com/MyScriptIcon
ExternalModuleDependencies : ExternalModule1
RequiredScripts : {Start-WFContosoServer, Stop-ContosoServerScript}
ExternalScriptDependencies : Stop-ContosoServerScript
Description : Contoso Script example
RequiredModules : {RequiredModule1, @{ ModuleName = 'RequiredModule2'; ModuleVersion = '1.0' }, @{ ModuleName = 'RequiredModule3'; RequiredVersion = '2.0' }, ExternalModule1}
ExportedCommands : {Test-WebUri, ValidateAndAdd-PSScriptInfoEntry, Get-PSScriptInfo, My-Workflow...}
ExportedFunctions : {Test-WebUri, ValidateAndAdd-PSScriptInfoEntry, Get-PSScriptInfo, My-AdvPSCmdlet}
ExportedWorkflows : My-Workflow
This command tests the script file Test-Runbook.ps1 and uses the pipeline operator to pass the results to the Format-List cmdlet to format the results.
Example 3: Test a script file that has no metadata
Test-ScriptFileInfo -Path "D:\code\Hello-World.ps1"
Test-ScriptFileInfo : Script 'D:\code\Hello-World.ps1' is missing required metadata properties. Verify that the script file has Version, Description
and Author properties. You can use the Update-ScriptFileInfo or New-ScriptFileInfo cmdlet to add or update the PSScriptInfo to the script file.
At line:1 char:1
+ Test-ScriptFileInfo D:\code\Hello-World.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (D:\code\Hello-World.ps1:String) [Test-ScriptFileInfo], ArgumentException
+ FullyQualifiedErrorId : MissingRequiredPSScriptInfoProperties,Test-ScriptFile
This command tests the script file Hello-World.ps1, which has no metadata associated with it.
Parameters
-LiteralPath
Specifies a path to one or more locations. Unlike the Path parameter, the value of the LiteralPath parameter is used exactly as it is entered. No characters are interpreted as wildcards. If the path includes escape characters, enclose them in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.
The parameter is mapped to the Path parameter of Test-PSScriptFileInfo
.
Type: | String |
Aliases: | PSPath |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Path
Specifies a path to one or more locations. Wildcards are permitted. The default location is the
current directory (.
).
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | True |