-
Notifications
You must be signed in to change notification settings - Fork 1
Get‑ClassResourceAst
Gets DSC class resource definitions from a PowerShell script file using AST parsing.
Get-ClassResourceAst -Path <String[]> [-ClassName <String>]
[<CommonParameters>]
Get-ClassResourceAst -ScriptFile <FileInfo[]> [-ClassName <String>]
[<CommonParameters>]
The Get-ClassResourceAst function parses a PowerShell script file and extracts DSC class resource definitions using Abstract Syntax Tree (AST) parsing. It filters for classes that have the [DscResource()] attribute. It can return all DSC class resources in the file or filter for a specific class by name.
Get-ClassResourceAst -Path 'C:\Scripts\MyDscResources.ps1'
Returns all DSC class resource definitions found in the specified script file.
Get-ClassResourceAst -Path 'C:\Scripts\MyDscResources.ps1' -ClassName 'MyDscResource'
Returns only the 'MyDscResource' DSC class resource definition from the specified script file.
'C:\Scripts\Resource1.ps1', 'C:\Scripts\Resource2.ps1' | Get-ClassResourceAst
Returns all DSC class resource definitions found in the specified script files using pipeline input.
Get-ChildItem -Path 'C:\Scripts\*.ps1' | Get-ClassResourceAst -ClassName 'MyDscResource'
Returns 'MyDscResource' DSC class resource definitions from all PowerShell script files in the specified directory.
Optional parameter to filter for a specific DSC class resource by name. If not provided, all DSC class resources in the script file are returned.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe path(s) to the PowerShell script file(s) to parse. Accepts pipeline input from strings (file paths).
Type: String[]
Parameter Sets: String
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: FalseFileInfo object(s) representing the PowerShell script file(s) to parse. Accepts pipeline input from Get-ChildItem and other commands that return FileInfo objects.
Type: FileInfo[]
Parameter Sets: FileInfo
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
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.
System.Collections.Generic.IEnumerable`1System.Management.Automation.Language.Ast
- Assert-GitLocalChange
- Assert-GitRemote
- Assert-IPv4Address
- Clear-AnsiSequence
- ConvertTo-AnsiSequence
- ConvertTo-AnsiString
- ConvertTo-DifferenceString
- ConvertTo-RelativePath
- Disable-CursorShortcutCode
- Get-ClassAst
- Get-ClassResourceAst
- Get-GitBranchCommit
- Get-GitLocalBranchName
- Get-GitRemote
- Get-GitRemoteBranch
- Get-GitTag
- Get-LinkLayerAddress
- Get-ModuleByVersion
- Get-ModuleFileSha
- Get-ModuleVersion
- Get-NumericalSequence
- Get-PSReadLineHistory
- Get-TextOffset
- Install-ModulePatch
- Invoke-Git
- Invoke-PesterJob
- New-GitTag
- New-SamplerGitHubReleaseTag
- Out-Difference
- Pop-VMLatestSnapshot
- Push-GitTag
- Receive-GitBranch
- Remove-GitTag
- Remove-History
- Remove-PSHistory
- Remove-PSReadLineHistory
- Rename-GitLocalBranch
- Rename-GitRemote
- Request-GitTag
- Resolve-DnsName
- Resume-GitRebase
- Send-WakeOnLan
- Split-StringAtIndex
- Start-GitRebase
- Stop-GitRebase
- Switch-GitLocalBranch
- Test-FileHash
- Test-GitLocalChanges
- Test-GitRemote
- Test-GitRemoteBranch
- Test-IPv4Address
- Update-GitLocalBranch
- Update-RemoteTrackingBranch