Get-AstScriptCommand¶
SYNOPSIS¶
Retrieves the commands used within a specified PowerShell script.
SYNTAX¶
Ast (Default)¶
Get-AstScriptCommand -Ast <Ast> [-Name <string>] [-Recurse] [-IncludeCallOperators]
[<CommonParameters>]
Path¶
Get-AstScriptCommand -Path <string> [-Name <string>] [-Recurse] [-IncludeCallOperators]
[<CommonParameters>]
Script¶
Get-AstScriptCommand -Script <string> [-Name <string>] [-Recurse] [-IncludeCallOperators]
[<CommonParameters>]
ALIASES¶
This cmdlet has the following aliases, {{Insert list of aliases}}
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-AstScriptCommand -Path "C:\Scripts\example.ps1"
Extracts and lists all commands found in the specified PowerShell script.
EXAMPLE 2¶
Get-AstScriptCommand -Path "C:\Scripts\example.ps1" -IncludeCallOperators
Extracts all commands, including those executed with call operators (& and .).
PARAMETERS¶
-Ast¶
An existing Ast object to search.
Type: System.Management.Automation.Language.Ast
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Ast
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-IncludeCallOperators¶
Include call operators in the results, i.e. & and .
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Name¶
The name of the function to search for. Defaults to all functions ('*').
Type: System.String
DefaultValue: '*'
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Path¶
The path to the PowerShell script file to be parsed. Validate using Test-Path
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Path
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Recurse¶
Search nested functions and script block expressions.
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Script¶
The PowerShell script to be parsed.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Script
Position: Named
IsRequired: true
ValueFromPipeline: true
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
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.
INPUTS¶
System.String¶
{{ Fill in the Description }}
System.Management.Automation.Language.Ast¶
{{ Fill in the Description }}