# Script to produce spreadsheets for the ImportExcel Public folder scripts # that contain: # The Function Name # The ParameterName # The Type # The Default value(s) # # Modify the $PublicFiles & $csvOutputFolder variables to suit your system. using namespace System.Management.Automation.Language $PublicFiles = "D:\Local_git_Repo\ImportExcel-master\Public" $csvOutputFolder = "D:\Test\ImportExcelModuleInfo" $FileNames = (Get-ChildItem $PublicFiles -Filter *.ps1) | Select-Object -Property Name -ExpandProperty Name $Files = $FileNames -replace ".ps1", "" ForEach ($File in $Files) { ForEach-Object { $ast = [Parser]::ParseFile("$PublicFiles\$File.ps1", [ref] $null, [ref] $null) $ast.FindAll({ $args[0] -is [FunctionDefinitionAst] }, $true) | ForEach-Object { $out = [ordered]@{ Function = $_.Name } $_.FindAll({ $args[0] -is [ParameterAst] }, $true) | ForEach-Object { $out['ParameterName'] = $_.Name.VariablePath $out['Type'] = $_.StaticType $out['DefaultValue'] = $_.DefaultValue $out['ScriptContent'] = $_ [pscustomobject] $out } } } | Export-Csv $csvOutputFolder\$File.csv -NoTypeInformation }