NAME
Test-ScriptFileInfo
SYNOPSIS
Validates a comment block for a script.SYNTAX
Test-ScriptFileInfo -LiteralPath
[ ] Test-ScriptFileInfo [-Path]
[ ] 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.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 Windows PowerShell not to interpret any characters as escape sequences. Required? true Position? named Default value NoneAccept pipeline input? True (ByPropertyName)
Accept wildcard characters? false-Path
Specifies a path to one or more locations. Wildcards are permitted. The default location is the current directory (.). Required? true Position? 0 Default value NoneAccept pipeline input? True (ByPropertyName)
Accept wildcard characters? falseThis cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable. For more information, see about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216). INPUTS
OUTPUTS
NOTES
Example 1: Test a script file
PS C:\>Test-ScriptFileInfo -Path "C:\temp\temp_scripts\New-ScriptFile.ps1"
Version Name Author Description
------- ---- ------ -----------
1.0 New-ScriptFile pattif my new script file test
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
PS C:\>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.0Guid : eb246b19-17da-4392-8c89-7c280f69ad0e
Author : pattifCompanyName : Microsoft Corporation
Copyright : Ac 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 : ExternalModule1RequiredScripts : {Start-WFContosoServer, Stop-ContosoServerScript}
ExternalScriptDependencies : Stop-ContosoServerScript
Description : Contoso Script exampleRequiredModules : {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
PS C:\>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, Descriptionand 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.
RELATED LINKS
Online Version: http://go.microsoft.com/fwlink/?LinkId=822336New-ScriptFileInfo
Publish-Script
Update-ScriptFileInfo