Skip to content

Latest commit

 

History

History
171 lines (112 loc) · 4.44 KB

File metadata and controls

171 lines (112 loc) · 4.44 KB

19. Modules in Powershell Part 3

Manifest Modules

Show-AdvancedScript.psd1

#
# Module manifest for module 'Show-AdvancedScript'
#
# Generated by: Administrator
#
# Generated on: 7/11/2017
#

@{

# Script module or binary module file associated with this manifest.
RootModule = 'Show-AdvancedScript.psm1'

# Version number of this module.
ModuleVersion = '1.0'

# ID used to uniquely identify this module
GUID = '57ee3f4b-356b-4417-90ab-134b533f845e'

# Author of this module
Author = 'Administrator'

# Company or vendor of this module
CompanyName = 'Unknown'

# Copyright statement for this module
Copyright = '(c) 2017 Administrator. All rights reserved.'

# Description of the functionality provided by this module
# Description = ''

# Minimum version of the Windows PowerShell engine required by this module
# PowerShellVersion = ''

# Name of the Windows PowerShell host required by this module
# PowerShellHostName = ''

# Minimum version of the Windows PowerShell host required by this module
# PowerShellHostVersion = ''

# Minimum version of Microsoft .NET Framework required by this module
# DotNetFrameworkVersion = ''

# Minimum version of the common language runtime (CLR) required by this module
# CLRVersion = ''

# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @()

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()

# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()

# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()

# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()

# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()

# Functions to export from this module
FunctionsToExport = '*_*'

# Cmdlets to export from this module
CmdletsToExport = '*'

# Variables to export from this module
VariablesToExport = '*'

# Aliases to export from this module
AliasesToExport = '*'

# List of all modules packaged with this module
# ModuleList = @()

# List of all files packaged with this module
# FileList = @()

# Private data to pass to the module specified in RootModule/ModuleToProcess
# PrivateData = ''

# HelpInfo URI of this module
# HelpInfoURI = ''

# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''

}
  • Creating a Manifest
PS C:\Users\Administrator\Desktop\19> ls


    Directory: C:\Users\Administrator\Desktop\19


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         7/11/2017  10:45 AM        494 Show-AdvancedScript.psm1


PS C:\Users\Administrator\Desktop\19>
PS C:\Users\Administrator\Desktop\19> New-ModuleManifest .\Show-AdvancedScript.psd1
PS C:\Users\Administrator\Desktop\19> ls


    Directory: C:\Users\Administrator\Desktop\19


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         7/11/2017  12:07 PM       5246 Show-AdvancedScript.psd1
-a---         7/11/2017  10:45 AM        494 Show-AdvancedScript.psm1


PS C:\Users\Administrator\Desktop\19>
  • Testing the Manifest Module
PS C:\Users\Administrator\Desktop\19> Test-ModuleManifest .\Show-AdvancedScript.psd1

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0        Show-AdvancedScript                 {Show-AdvancedScript, Test-FileExistence}


PS C:\Users\Administrator\Desktop\19>
  • Using the manifest

    • Importing the module
    PS C:\Users\Administrator\Desktop\19> Import-Module .\Show-AdvancedScript.psd1 -Verbose
    VERBOSE: Loading module from path 'C:\Users\Administrator\Desktop\19\Show-AdvancedScript.psd1'.
    VERBOSE: Importing function 'Show-AdvancedScript'.
    VERBOSE: Importing function 'Test-FileExistence'.
    PS C:\Users\Administrator\Desktop\19>
    • Importing the module with the Version
    PS C:\Users\Administrator\Desktop\19> Import-Module .\Show-AdvancedScript.psd1 -Version 1.0