Tests/TemplateTest.ps1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
[CmdletBinding(SupportsShouldProcess = $True)] Param( ) #region Init #Load default arguemts for this script from the dfp setting files. #Command prompt arguments will override any settings function GetLocalDefaultsFromDfpFiles($CallerInvocation) { #Load script default settings foreach($settingsFile in (Get-SettingsFiles $CallerInvocation ".dfp")) { #Write-Host "File: [$settingsFile]" if (Test-Path $settingsFile) { $settings = Get-Content $settingsFile #Enumerate settingsfile rows foreach($row in $settings) { #Remarked lines are not processed if (($row -match "=") -and ($row.Trim().SubString(0,1) -ne "#")) { $key = $row.Split('=')[0] $var = Get-Variable $key -ErrorAction SilentlyContinue if ($var -and !($var.Value)) { try { $var.Value = Invoke-Expression $row.SubString($key.Length+1) } Catch { $ex = $PSItem $ex.ErrorDetails = "Err adding $key from $settingsFile. " + $PSItem.Exception.Message throw $ex } } #Write-Host "$($var.Value)" } } } } } #Load the module get-module PSJumpStart | Remove-Module; Import-Module PSJumpStart #Get Local variable default values from external DFP-files GetLocalDefaultsFromDfpFiles($MyInvocation) #Get global deafult settings when calling modules $PSDefaultParameterValues = Get-GlobalDefaultsFromDfpFiles($MyInvocation) #endregion Msg "Start Execution" Msg "List All templates" Find-PSTemplate Msg "List 'argument' templates" Find-PSTemplate -Name "*arg*" Msg "Copy PSJumpStart templates to current location" Copy-PSTemplate -Name "PSJumpStart*" Msg "End Execution" |