Skip to content

Add PSProfileInitScript

Nate Ferrell edited this page Sep 23, 2019 · 1 revision

Add-PSProfileInitScript

SYNOPSIS

Adds script contents to your PSProfile configuration directly. Contents will be invoked during PSProfile import. Useful for scripts that you want to include directly on your configuration for portability instead of calling as an external script via $PSProfile.ScriptPaths.

SYNTAX

Content (Default)

Add-PSProfileInitScript [-Name] <String> [-Content] <String[]> [-State <String>] [-Force] [-Save]
 [<CommonParameters>]

ScriptBlock

Add-PSProfileInitScript [-Name] <String> [-ScriptBlock] <ScriptBlock> [-State <String>] [-Force] [-Save]
 [<CommonParameters>]

Path

Add-PSProfileInitScript -Path <String[]> [-State <String>] [-RemoveDuplicateScriptPaths] [-Force] [-Save]
 [<CommonParameters>]

DESCRIPTION

Adds script contents to your PSProfile configuration directly. Contents will be invoked during PSProfile import. Useful for scripts that you want to include directly on your configuration for portability instead of calling as an external script via $PSProfile.ScriptPaths.

EXAMPLES

EXAMPLE 1

Get-PSProfileScriptPath | Add-PSProfileInitScript

PARAMETERS

-Name

The friendly name to reference the script block by.

Type: String
Parameter Sets: Content, ScriptBlock
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Content

The content of the script as a string, i.e. if using `Get-Content` against another file to pass as the value here.

Type: String[]
Parameter Sets: Content
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ScriptBlock

The content of the script as a scriptblock. Useful if you are adding as script manually

Type: ScriptBlock
Parameter Sets: ScriptBlock
Aliases:

Required: True
Position: 2
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Path

The path to an external PS1 file to import the contents to your $PSProfile.InitScripts directly. When using Path, the file's BaseName becomes the Name value.

Type: String[]
Parameter Sets: Path
Aliases: FullName

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False

-State

Whether the InitScript should be Enabled or Disabled. Defaults to Enabled.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: Enabled
Accept pipeline input: False
Accept wildcard characters: False

-RemoveDuplicateScriptPaths

If a specified Path is also in $PSProfile.ScriptPaths, remove it from there to prevent duplicate scripts from being invoked during PSProfile import.

Type: SwitchParameter
Parameter Sets: Path
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Force

If the InitScript name already exists in $PSProfile.InitScripts, use -Force to overwrite the existing value.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Save

If $true, saves the updated PSProfile after updating.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

RELATED LINKS

PSProfile

Concepts

Function Help

Command Aliases

Configuration

Helpers

Init Scripts

Meta

Modules to Import

Modules to Install

Path Aliases

Plugin Paths

Plugins

Power Tools

Project Paths

Prompts

Script Paths

Secrets

Symbolic Links

Variables

Badges

Azure Pipelines      Discord - Chat      Slack - Chat      Codacy PowerShell Gallery      GitHub Releases      GitHub Releases

Clone this wiki locally