Archve/Split-PrivateFunctions.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ModuleFile = "D:\GitHub\Modules\OSDBuilder\Private\AllFunctions.ps1" # path to your PSM1 file
$ExportPath = "D:\GitHub\Modules\OSDBuilder\PrivateSplit" # path where to export functions into separate PS1 files. Skip the trailing \
$AST = [System.Management.Automation.Language.Parser]::ParseFile(
    $ModuleFile,
    [ref]$null,
    [ref]$Null
)

$AST.FindAll({
    $args[0] -is [System.Management.Automation.Language.FunctionDefinitionAst]}
    , $true) | foreach {
    $_.Extent.Text | Out-File -Append "$ExportPath\$($_.name).ps1"
}

Return
Get-ChildItem D:\GitHub\Modules\OSDBuilder\PrivateSplit\*.ps1 | Get-Content | Add-Content "D:\GitHub\Modules\OSDBuilder\Private\AllFunctions.ps1"