| external help file | PSModule-help.xml |
|---|---|
| Locale | en-US |
| Module Name | PowerShellGet |
| ms.date | 07/01/2019 |
| online version | https://learn.microsoft.com/powershell/module/powershellget/new-scriptfileinfo?view=powershellget-1.x&WT.mc_id=ps-gethelp |
| schema | 2.0.0 |
| title | New-ScriptFileInfo |
Creates a script file with metadata.
New-ScriptFileInfo [[-Path] <String>] [-Version <Version>] [-Author <String>] -Description <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[]>] [-PassThru] [-Force] [-WhatIf] [-Confirm]
[<CommonParameters>]
The New-ScriptFileInfo cmdlet creates a PowerShell script file, including metadata about the
script.
The examples use splatting to pass parameters to the New-ScriptFileInfo cmdlet. For more
information, see about_Splatting.
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.
In this example, the metadata for the script created in Example 1 is tested.
Test-ScriptFileInfo -Path C:\Test\Temp-Scriptfile.ps1Version 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 @ParmsVERBOSE: 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()
Specifies the script author.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the company or vendor who created the script.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a copyright statement for the script.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a description for the script.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies an array of external module dependencies.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies an array of external script dependencies.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseForces the command to run without asking for user confirmation.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a unique ID for the script.
Type: System.Guid
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the URL of an icon for the script. The specified icon is displayed on the gallery web page for the script.
Type: System.Uri
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the URL of licensing terms.
Type: System.Uri
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseReturns an object that represents the item with which you're working. By default,
New-ScriptFileInfo doesn't generate any output.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the location where the script file is saved.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: 0
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: FalseSpecifies the URL of a web page about this project.
Type: System.Uri
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies a string array that contains release notes or comments that you want available to users of this version of the script.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies modules that must be in the global session state. If the required modules aren't in the global session state, PowerShell imports them.
Type: System.Object[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies an array of required scripts.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies an array of tags.
Type: System.String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies the version of the script.
Type: System.String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalsePrompts you for confirmation before running the New-ScriptFileInfo.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseShows what would happen if New-ScriptFileInfo runs. The cmdlet isn't run.
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.