Skip to content

New-CommanderContextMenu

SYNOPSIS

Creates a context menu item that executes PowerShell.

SYNTAX

New-CommanderContextMenu [-Action] <ScriptBlock> [-Text] <String> [[-Location] <String>]
 [[-Extension] <String>] [-DisplayOnShiftClick] [[-Position] <String>] [[-Icon] <String>]
 [[-IconIndex] <Int32>] [<CommonParameters>]

DESCRIPTION

Creates a context menu item that executes PowerShell.

EXAMPLES

EXAMPLE 1

New-CommanderContextMenu -Text 'Click me' -Action {
    Start-Process code -ArgumentList $args[0]
}

Starts VS Code and opens the file that was right clicked.

PARAMETERS

-Action

The script block action to execute. $Args[0] will include the path the was right clicked.

Type: System.Management.Automation.ScriptBlock
Parameter Sets: (All)
Aliases:

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

-Text

The text to display.

Type: System.String
Parameter Sets: (All)
Aliases:

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

-Location

The location to display this context menu item. File will display this action when right clicking on the associated file extension. FolderLeftPane will display when right clicking on a folder in the left pane of the explorer window. FolderRightPane will display when right clicking on the folder in the right pane of the explorer window or the desktop.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: File
Accept pipeline input: False
Accept wildcard characters: False

-Extension

The extension to associate this context menu item to. This requires that Location is set to File.

Type: System.String
Parameter Sets: (All)
Aliases:

Required: False
Position: 4
Default value: *
Accept pipeline input: False
Accept wildcard characters: False

-DisplayOnShiftClick

Displays this option only when shift is help down during the right click.

Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

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

-Position

The location to position this context menu item. You can select Top, Bottom and None. None is the default.

Type: System.String
Parameter Sets: (All)
Aliases:

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

-Icon

An icon to display for this context menu item.

Type: System.String
Parameter Sets: (All)
Aliases:

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

-IconIndex

The index within the icon file to use.

Type: System.Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 7
Default value: 0
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

Back to top