Get-ScriptCommand¶
SYNOPSIS¶
Retrieves the commands used within a specified PowerShell script.
SYNTAX¶
Get-ScriptCommand [-Path] <String> [-IncludeCallOperators] [-ProgressAction <ActionPreference>]
[<CommonParameters>]
DESCRIPTION¶
Analyzes a given PowerShell script and extracts all command invocations. Optionally includes call operators (& and .) in the results. Returns details such as command name, position, and file reference.
EXAMPLES¶
EXAMPLE 1¶
Get-ScriptCommand -Path "C:\Scripts\example.ps1"
Extracts and lists all commands found in the specified PowerShell script.
EXAMPLE 2¶
Get-ScriptCommand -Path "C:\Scripts\example.ps1" -IncludeCallOperators
Extracts all commands, including those executed with call operators (& and .).
PARAMETERS¶
-Path¶
The path to the PowerShell script file to be parsed.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-IncludeCallOperators¶
Include call operators in the results, i.e. & and .
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
-ProgressAction¶
{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
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¶
https://psmodule.io/AST/Functions/Scripts/Get-ScriptCommand/