New-ScriptFileInfo
Creates a script file with metadata.
Syntax
All
New-ScriptFileInfo
[[-Path] <String>]
-Description <String>
[-Version <String>]
[-Author <String>]
[-Guid <Guid>]
[-CompanyName <String>]
[-Copyright <String>]
[-RequiredModules <Object[]>]
[-ExternalModuleDependencies <String[]>]
[-RequiredScripts <String[]>]
[-ExternalScriptDependencies <String[]>]
[-Tags <String[]>]
[-ProjectUri <Uri>]
[-LicenseUri <Uri>]
[-IconUri <Uri>]
[-ReleaseNotes <String[]>]
[-PrivateData <String>]
[-PassThru]
[-Force]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The New-ScriptFileInfo
cmdlet creates a PowerShell script file, including metadata about the
script.
This is a proxy cmdlet for the New-PSScriptFileInfo
cmdlet in the
Microsoft.PowerShell.PSResourceGet . For more information, see
New-PSScriptFileInfo .
Examples
Example 1: Create a script file and specify its version, author, and description
In this example, a script file is created and its contents are displayed in the PowerShell console.
$Parms = @{
Path = "C:\Test\Temp-Scriptfile.ps1"
Version = "1.0"
Author = "pattif@contoso.com"
Description = "My test script file description goes here"
}
New-ScriptFileInfo @Parms
Get-Content -Path C:\Test\Temp-Scriptfile.ps1
<#PSScriptInfo
.VERSION 1.0
.GUID 3bb10ee7-38c1-41b9-88ea-16899164fc19
.AUTHOR pattif@contoso.com
.COMPANYNAME
.COPYRIGHT
.TAGS
.LICENSEURI
.PROJECTURI
.ICONURI
.EXTERNALMODULEDEPENDENCIES
.REQUIREDSCRIPTS
.EXTERNALSCRIPTDEPENDENCIES
.RELEASENOTES
.PRIVATEDATA
#>
<#
.DESCRIPTION
My test script file description goes here
#>
Param()
The New-ScriptFileInfo
cmdlet uses splatting to configure several parameters for the script.
Path sets the ___location and name of the script. Version specifies the script's version
number. Author is the email address of the person who created the script. Description
explains the script's purpose.
After the script is created, Get-Content
uses the Path parameter to locate the script. The
script's contents are displayed in the PowerShell console.
Example 2: Test a script file
In this example, the metadata for the script created in Example 1 is tested.
Test-ScriptFileInfo -Path C:\Test\Temp-Scriptfile.ps1
Version Name Author Description
------- ---- ------ -----------
1.0 Temp-Scriptfile pattif@contoso.com My test script file description goes here
The Test-ScriptFileInfo
cmdlet uses the Path parameter to specify the script file's ___location.
This example uses splatting to create a script file named New-ScriptFile.ps1
that includes all its
metadata properties. The Verbose parameter specifies that verbose output is displayed as the
script is created.
$Parms = @{
Path = "C:\Test\New-ScriptFile.ps1"
Verbose = $True
Version = "1.0"
Author = "pattif@contoso.com"
Description = "My new script file test"
CompanyName = "Contoso Corporation"
Copyright = "2019 Contoso Corporation. All rights reserved."
ExternalModuleDependencies = "ff","bb"
RequiredScripts = "Start-WFContosoServer", "Stop-ContosoServerScript"
ExternalScriptDependencies = "Stop-ContosoServerScript"
Tags = @("Tag1", "Tag2", "Tag3")
ProjectUri = "https://contoso.com"
LicenseUri = "https://contoso.com/License"
IconUri = "https://contoso.com/Icon"
PassThru = $True
ReleaseNotes = @("Contoso script now supports the following features:",
"Feature 1",
"Feature 2",
"Feature 3",
"Feature 4",
"Feature 5")
RequiredModules =
"1",
"2",
"RequiredModule1",
@{ModuleName="RequiredModule2";ModuleVersion="1.0"},
@{ModuleName="RequiredModule3";RequiredVersion="2.0"},
"ExternalModule1"
}
New-ScriptFileInfo @Parms
VERBOSE: Performing the operation "Creating the 'C:\Test\New-ScriptFile.ps1'
PowerShell Script file" on target "C:\Test\New-ScriptFile.ps1".
<#PSScriptInfo
.VERSION 1.0
.GUID 4fabe8c7-7862-45b1-a72e-1352a433b77d
.AUTHOR pattif@contoso.com
.COMPANYNAME Contoso Corporation
.COPYRIGHT 2019 Contoso Corporation. All rights reserved.
.TAGS Tag1 Tag2 Tag3
.LICENSEURI https://contoso.com/License
.PROJECTURI https://contoso.com/
.ICONURI https://contoso.com/Icon
.EXTERNALMODULEDEPENDENCIES ff,bb
.REQUIREDSCRIPTS Start-WFContosoServer,Stop-ContosoServerScript
.EXTERNALSCRIPTDEPENDENCIES Stop-ContosoServerScript
.RELEASENOTES
Contoso script now supports the following features:
Feature 1
Feature 2
Feature 3
Feature 4
Feature 5
.PRIVATEDATA
#>
#Requires -Module 1
#Requires -Module 2
#Requires -Module RequiredModule1
#Requires -Module @{ModuleName = 'RequiredModule2'; ModuleVersion = '1.0'}
#Requires -Module @{RequiredVersion = '2.0'; ModuleName = 'RequiredModule3'}
#Requires -Module ExternalModule1
<#
.DESCRIPTION
My new script file test
#>
Param()
Parameters
-Author
Specifies the script author.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-CompanyName
Specifies the company or vendor who created the script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Confirm
Prompts you for confirmation before running the New-ScriptFileInfo
.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: cf
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Copyright
Specifies a copyright statement for the script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Description
Specifies a description for the script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: True
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ExternalModuleDependencies
Specifies an array of external module dependencies.
Parameter properties
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ExternalScriptDependencies
Specifies an array of external script dependencies.
Parameter properties
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Force
Forces the command to run without asking for user confirmation.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Guid
Specifies a unique ID for the script.
Parameter properties
Type: Guid
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-IconUri
Specifies the URL of an icon for the script. The specified icon is displayed on the gallery web page
for the script.
Parameter properties
Type: Uri
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-LicenseUri
Specifies the URL of licensing terms.
Parameter properties
Type: Uri
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-PassThru
The proxy cmdlet ignores this parameter since it's not supported by New-PSScriptFileInfo
.
Parameter properties
Type: SwitchParameter
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Path
Specifies the ___location where the script file is saved.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: 0
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: True
Value from remaining arguments: False
-PrivateData
Specifies private data for the script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ProjectUri
Specifies the URL of a web page about this project.
Parameter properties
Type: Uri
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-ReleaseNotes
Specifies a string array that contains release notes or comments that you want available to users of
this version of the script.
Parameter properties
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-RequiredModules
Specifies modules that must be in the global session state. If the required modules aren't in the
global session state, PowerShell imports them.
Parameter properties
Type: Object [ ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-RequiredScripts
Specifies an array of required scripts.
Parameter properties
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
Specifies an array of tags.
Type: String [ ]
Default value: None
Supports wildcards: False
DontShow: False
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-Version
Specifies the version of the script.
Parameter properties
Type: String
Default value: None
Supports wildcards: False
DontShow: False
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
-WhatIf
Shows what would happen if New-ScriptFileInfo
runs. The cmdlet isn't run.
Parameter properties
Type: SwitchParameter
Default value: False
Supports wildcards: False
DontShow: False
Aliases: wi
Parameter sets
(All)
Position: Named
Mandatory: False
Value from pipeline: False
Value from pipeline by property name: False
Value from remaining arguments: False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters .
Outputs