Test-ScriptFileInfo
스크립트에 대한 주석 블록의 유효성을 검사합니다.
구문
Test-ScriptFileInfo
[-Path] <String>
[<CommonParameters>]
Test-ScriptFileInfo
-LiteralPath <String>
[<CommonParameters>]
Description
cmdlet은 Test-ScriptFileInfo
Publish-Script cmdlet과 함께 게시될 스크립트의 시작 부분에 있는 주석 블록의 유효성을 검사합니다. 주석 블록에 오류가 있으면 이 cmdlet은 오류가 있는 위치 또는 오류를 수정하는 방법에 대한 정보를 반환합니다.
Microsoft.PowerShell.PSResourceGet의 Test-PSScriptFileInfo
cmdlet에 대한 프록시 cmdlet입니다. 자세한 내용은 Test-PSScriptFileInfo를 참조하세요.
예제
예제 1: 스크립트 파일 테스트
Test-ScriptFileInfo -Path "C:\temp\temp_scripts\New-ScriptFile.ps1"
이 명령은 New-ScriptFile.ps1 스크립트 파일을 테스트하고 결과를 표시합니다. 스크립트 파일에는 유효한 메타데이터가 포함됩니다.
예제 2: 모든 메타데이터 속성에 대한 값이 있는 스크립트 파일 테스트
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
이 명령은 스크립트 파일 Test-Runbook.ps1 테스트하고 파이프라인 연산자를 사용하여 결과를 Format-List cmdlet에 전달하여 결과의 형식을 지정합니다.
예제 3: 메타데이터가 없는 스크립트 파일 테스트
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
이 명령은 연결된 메타데이터가 없는 스크립트 파일 Hello-World.ps1테스트합니다.
매개 변수
-LiteralPath
하나 이상의 위치에 대한 경로를 지정합니다. Path 매개 변수와 달리 LiteralPath 매개 변수의 값은 입력된 대로 정확하게 사용됩니다. 와일드카드로 해석되는 문자는 없습니다. 경로에 이스케이프 문자가 포함된 경우 작은따옴표로 묶습니다. 작은따옴표는 PowerShell에 문자를 이스케이프 시퀀스로 해석하지 않도록 지시합니다.
매개 변수는 .의 Test-PSScriptFileInfo
Path 매개 변수에 매핑됩니다.
형식: | String |
별칭: | PSPath |
Position: | Named |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | True |
와일드카드 문자 허용: | False |
-Path
하나 이상의 위치에 대한 경로를 지정합니다. 와일드카드가 허용됩니다. 기본 위치는 현재 디렉터리(.
)입니다.
형식: | String |
Position: | 0 |
Default value: | None |
필수: | True |
파이프라인 입력 허용: | True |
와일드카드 문자 허용: | True |