Verifies that a module manifest file accurately describes the contents of a module. (Test-ModuleManifest)

   

# NAME
Test-ModuleManifest

# SYNOPSIS
Verifies that a module manifest file accurately describes the contents of a module.

# SYNTAX
Test-ModuleManifest [-Path] <string> [<CommonParameters>]

# DESCRIPTION
The Test-ModuleManifest cmdlet verifies that the files that are listed in the module manifest (.psd1) file actually exist in the specified paths.

This cmdlet is designed to help module authors test their manifest files. Module users can also use this cmdlet in scripts and commands to detect errors before running scripts that depend on the module.

The Test-ModuleManifest cmdlet returns an object that represents the module (the same type of object that Get-Module returns). If any files are not in the locations specified in the manifest, the cmdlet also generates an error for each missing file.

# PARAMETERS
-Path <string>
Specifies the path to the module manifest file. Enter a path (optional) and the name of the module manifest file with the .psd1 file name extension. The default location is the current directory. This parameter is required. The parameter name ("Path") is optional. You can also pipe a path to Test-ModuleManifest.

Required? true
Position? 1
Default value None
Accept pipeline input? true (ByValue, ByPropertyName)
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
System.String
You can pipe the path to a module manifest to Test-ModuleManifest.

# OUTPUTS
System.Management.Automation.PSModuleInfo
Test-ModuleManifest returns a PSModuleInfo object that represents the module. It returns this object even if the manifest has errors.

# NOTES

# EXAMPLE 1

C:\PS>test-ModuleManifest -path $pshome\Modules\TestModule.psd1

# Description
-----------
This command tests the TestModule.psd1 module manifest.

# EXAMPLE 2

C:\PS>"$pshome\Modules\TestModule.psd1" | test-modulemanifest

Test-ModuleManifest : The specified type data file 'C:\Windows\System32\Wi
ndowsPowerShell\v1.0\Modules\TestModule\TestTypes.ps1xml' could not be pro
cessed because the file was not found. Please correct the path and try aga
in.
At line:1 char:34
+ "$pshome\Modules\TestModule.psd1" | test-modulemanifest <<<<
+ CategoryInfo : ResourceUnavailable: (C:\Windows\System32\Win
dowsPowerShell\v1.0\Modules\TestModule\TestTypes.ps1xml:String) [Test-Modul
eManifest], FileNotFoundException
+ FullyQualifiedErrorId : Modules_TypeDataFileNotFound,Microsoft.
PowerShell.Commands.TestModuleManifestCommandName

Name : TestModule
Path : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Test
Module\TestModule.psd1
# Description :
Guid : 6f0f1387-cd25-4902-b7b4-22cff6aefa7b
Version : 1.0
ModuleBase : C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Test
Module
ModuleType : Manifest
PrivateData :
AccessMode : ReadWrite
ExportedAliases : {}
ExportedCmdlets : {}
ExportedFunctions : {}
ExportedVariables : {}
NestedModules : {}

# Description
-----------
This command uses a pipeline operator (|) to send a path string to Test-ModuleManifest.

The command output shows that the test failed, because the TestTypes.ps1xml file, which was listed in the manifest, was not found.

# EXAMPLE 3

C:\PS>function Bool-ModuleManifest ($path)
{$a = dir $path | test-modulemanifest -erroraction SilentlyContinue; $?}

# Description
-----------
This function is like Test-ModuleManifest, but it returns a Boolean value; it returns "True" if the manifest passed the test and "False" otherwise.

The function uses the Get-ChildItem cmdlet (alias = dir) to get the module manifest specified by the $path variable. It uses a pipeline operator (|) to pass the file object to the Test-ModuleManifest cmdlet.

The Test-ModuleManifest command uses the ErrorAction common parameter with a value of SilentlyContinue to suppress the display of any errors that the command generates. It also saves the PSModuleInfo object that Test-ModuleManifest returns in the $a variable, so the object is not displayed.

Then, in a separate command (the semi-colon [;] is the command separator), it displays the value of the $? automatic variable, which returns "True" if the previous command generated no error and "False" otherwise.

You can use this function in conditional statements, such as those that might precede an Import-Module command or a command that uses the module.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=141557
Import-Module
Get-Module
New-Module
Remove-Module
Export-ModuleMember
New-ModuleManifest
about_Modules

C:\Windows>powershell get-help Add-PSSnapin -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole









... Windows-10




Windows 10 How To

... Windows 10 FAQ
... Windows 10 How To




PowerShell: Verifies that a module manifest file accurately describes the contents of a module.

HTTP: ... PS_Windows/en/Test-ModuleManifest.htm
0.265
16156

Command prompt Save program parameter arguments as favorites!

 /

QTP als eine Art Translator, der deutsche Texte im Menü als Englische einfügt?

 /

Start Windows 10/11 Task Manager!

 /

Wo finde ich den PC Leistungsindex in Windows 8.1 / 10 (Computer, Bewertung)?

 /

Windows 10/11 OEM and full version, difference?

 /

Securely delete data from hard drives with DiskPart via command prompt!

 /

Windows 10 auto update hangs at 91 percent, why, what can i do?

 /

Use specific icon layout for windows startup!

 /

Has Quad-Directory Explorer a single tree that can be used for all panes?

 /

Can I open the installed applications (APPs) on my Samsung Galaxy?

 /

Mit Wasserzeichen die Bilder schützen um das Kopieren zu reduzieren!

 /

Wie formatiere ich die Festplatte unter Windows 7?

 /