Created
January 18, 2022 20:29
-
-
Save sowderca/83c8e44434a2d9dea33eef96fb4a0b76 to your computer and use it in GitHub Desktop.
Exclude based upon attribute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-ChildItem -Path './src' -Filter '*.ps1' -File -Recurse | ForEach-Object { | |
$functions = (Get-Command $_.FullName).ScriptBlock.Ast.FindAll( { $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst] }, $false); | |
foreach ($func in $functions) { | |
[ScriptBlock] $code = [ScriptBlock]::Create("function tmp-$($func.Name) $($func.Body)"); | |
New-Module -Name 'tmp-mod' -ScriptBlock $code | Out-Null; | |
[PSCustomObject] @{ | |
File = $_.Name; | |
Function = $func.Name; | |
Attributes = (Get-Command -Name "tmp-$($func.Name)").ScriptBlock.Attributes | % { ${PSItem}?.TypeId?.Name } | |
}; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment