Function Get-ContentFromFilesInPath { <# .SYNOPSIS Collects all content from valid files for inclusion into the PSM1 .DESCRIPTION Collects all content from valid files for inclusion into the PSM1 * Skips test files * Adds a header line saying where the file came from during compile The reason for these files to match their names is about process, not a functional concern. .EXAMPLE Get-ContentFromFilesInPath .\Alkami.PowerShell.IIS\ .PARAMETER FolderPath The name of the folder to examine all files under. #> [CmdletBinding()] Param ( [String]$FolderPath ) process { $functionLines = @() $prefixPath = (Split-Path $FolderPath -leaf) $files = (Get-ChildItem (Join-Path $FolderPath "*.ps1")) foreach($file in $files) { if ($file.BaseName.ToLower().EndsWith(".tests") -or $file.BaseName.ToLower().EndsWith(".test")) { Write-Verbose "skipping function names of test $file" } elseif ($file.BaseName.ToLower() -eq "variabledeclarations") { $content = Get-Content $file.FullName $functionLines += @("## Function from $file") if ($null -ne $content -and $content[0] -match "SuppressMessageAttribute" -and $content[1] -match "param\(\)") { Write-Host "Skipping PSScriptAnalyzer and Param Declaration from $($file.FullName)" -ForegroundColor Green $functionLines += ($content | Select-Object -Skip 2) } else { $functionLines += $content } } else { $functionLines += @("## Function from $file") $functionLines += (Get-Content $file.FullName) } $functionLines += "" } return $functionLines } }