Aracılığıyla paylaş


Test-ScriptFileInfo

Betik için açıklama bloğunu doğrular.

Syntax

PathParameterSet (Varsayılan)

Test-ScriptFileInfo
    [-Path] <String>
    [<CommonParameters>]

LiteralPathParameterSet

Test-ScriptFileInfo
    -LiteralPath <String>
    [<CommonParameters>]

Description

cmdlet'i Test-ScriptFileInfo , Publish-Script cmdlet'iyle yayımlanacak bir betiğin başındaki açıklama bloğunu doğrular. Açıklama bloğunda bir hata varsa, bu cmdlet hatanın nerede bulunduğu veya nasıl düzeltileceği hakkında bilgi döndürür.

Örnekler

Örnek 1: Betik dosyasını test edin

Test-ScriptFileInfo -Path "C:\temp\temp_scripts\New-ScriptFile.ps1"

Bu komut New-ScriptFile.ps1 betik dosyasını sınar ve sonuçları görüntüler. Betik dosyası geçerli meta veriler içerir.

Örnek 2: Tüm meta veri özellikleri için değerleri olan bir betik dosyasını test edin

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

Bu komut Test-Runbook.ps1 betik dosyasını test eder ve sonuçları biçimlendirmek için sonuçları Format-List cmdlet'ine geçirmek için işlem hattı işlecini kullanır.

Örnek 3: Meta veri içermeyen bir betik dosyasını test edin

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

Bu komut, kendisiyle ilişkilendirilmiş meta veri içermeyen Hello-World.ps1betik dosyasını test eder.

Parametreler

-LiteralPath

Bir veya daha fazla konumun yolunu belirtir. Path parametresinden farklı olarak, LiteralPath parametresinin değeri tam olarak girildiğinde kullanılır. Hiçbir karakter joker karakter olarak yorumlanmamıştır. Yol kaçış karakterleri içeriyorsa, bunları tek tırnak içine alın. Tek tırnak işaretleri, PowerShell'in hiçbir karakteri kaçış dizisi olarak yorumlamamasını sağlar.

Parametre özellikleri

Tür:String
Default value:None
Joker karakterleri destekler:False
DontShow:False
Diğer adlar:PSPath

Parametre kümeleri

LiteralPathParameterSet
Position:Named
Zorunlu:True
İşlem hattından gelen değer:False
Özellik adına göre işlem hattından gelen değer:True
Kalan bağımsız değişkenlerden elde edilen değer:False

-Path

Bir veya daha fazla konumun yolunu belirtir. Joker karakterlere izin verilir. Varsayılan konum geçerli dizindir (.).

Parametre özellikleri

Tür:String
Default value:None
Joker karakterleri destekler:True
DontShow:False

Parametre kümeleri

PathParameterSet
Position:0
Zorunlu:True
İşlem hattından gelen değer:False
Özellik adına göre işlem hattından gelen değer:True
Kalan bağımsız değişkenlerden elde edilen değer:False

CommonParameters

Bu cmdlet yaygın parametreleri destekler: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction ve -WarningVariable. Daha fazla bilgi için bkz. about_CommonParameters.

Girişler

String

Çıkışlar

Object