Skip to content

Instantly share code, notes, and snippets.

@techthoughts2
Created February 21, 2022 00:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techthoughts2/354c962f36fba10806f4e6282b5fc646 to your computer and use it in GitHub Desktop.
Save techthoughts2/354c962f36fba10806f4e6282b5fc646 to your computer and use it in GitHub Desktop.
Get-ChildItem -Filter *.ps1 | ForEach-Object {
$ast = [System.Management.Automation.Language.Parser]::ParseFile($_.FullName, [ref]$null, [ref]$null)
$ast.FindAll({ param($sa) $sa -is [System.Management.Automation.Language.FunctionDefinitionAst] }, $false) | ForEach-Object {
# Define functions
New-Item -Path Function:\ -Name $_.Name -Value $_.Body.GetScriptBlock()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment