diff --git a/src/ScheduledTaskManagement/Public/Setup-ScheduledTask.ps1 b/src/ScheduledTaskManagement/Public/Setup-ScheduledTask.ps1 index 3d5c7c7..072a422 100644 --- a/src/ScheduledTaskManagement/Public/Setup-ScheduledTask.ps1 +++ b/src/ScheduledTaskManagement/Public/Setup-ScheduledTask.ps1 @@ -22,31 +22,31 @@ function Setup-ScheduledTask { try { # Import definitions as an array of hashtable definitions $DefinitionsCollection = New-Object System.Collections.ArrayList - if ($PSBoundParameters['DefinitionFile']) { - $DefinitionFileCollection = Get-Item $PSBoundParameters['DefinitionFile'] - }elseif ($PSBoundParameters['DefinitionDirectory']) { - $DefinitionFileCollection = if ($PSBoundParameters['AsJson']) { - Get-ChildItem $PSBoundParameters['DefinitionDirectory'] -File | ? { $_.Extension -eq '.json' } + if ($DefinitionFile) { + $DefinitionFileCollection = Get-Item $DefinitionFile + }elseif ($DefinitionDirectory) { + $DefinitionFileCollection = if ($AsJson) { + Get-ChildItem $DefinitionDirectory -File | ? { $_.Extension -eq '.json' } }else { - Get-ChildItem $PSBoundParameters['DefinitionDirectory'] -File | ? { $_.Extension -eq '.ps1' } + Get-ChildItem $DefinitionDirectory -File | ? { $_.Extension -eq '.ps1' } } } - if (!$PSBoundParameters['DefinitionObject']) { + if (!$DefinitionObject) { if (!$DefinitionFileCollection) { "No definitions could be found from the specified definition files or directories." | Write-Error return } } - if (!$PSBoundParameters['DefinitionObject']) { + if (!$DefinitionObject) { $DefinitionCollectionRaw = $DefinitionFileCollection | % { - if ($PSBoundParameters['AsJson']) { - Get-Content -Path $_.FullName | ConvertFrom-Json + if ($AsJson) { + Get-Content $_.FullName | ConvertFrom-Json }else { . $_.FullName } } - }elseif ($PSBoundParameters['DefinitionObject']) { - $DefinitionCollectionRaw = $PSBoundParameters['DefinitionObject'] + }elseif ($DefinitionObject) { + $DefinitionCollectionRaw = $DefinitionObject } $DefinitionCollectionRaw | % { $definitionHashtable = if ($_.GetType() -ne [hashtable]) { $_ | ConvertTo-Hashtable } else { $_ } diff --git a/src/ScheduledTaskManagement/ScheduledTaskManagement.psm1 b/src/ScheduledTaskManagement/ScheduledTaskManagement.psm1 index 5fdd132..7624e85 100644 --- a/src/ScheduledTaskManagement/ScheduledTaskManagement.psm1 +++ b/src/ScheduledTaskManagement/ScheduledTaskManagement.psm1 @@ -12,9 +12,9 @@ $script:MODULE['PRIVATE_DIR'] = Join-Path $script:MODULE['BASE_DIR'] 'Private' $script:MODULE['HELPERS_DIR'] = Join-Path $script:MODULE['BASE_DIR'] 'helpers' # Module helpers # Load vendor, Public, Private, classes, helpers -Get-ChildItem -Path "$($script:MODULE['PUBLIC_DIR'])\*.ps1" | % { . $_.FullName } -Get-ChildItem -Path "$($script:MODULE['PRIVATE_DIR'])\*.ps1" | % { . $_.FullName } -Get-ChildItem -Path "$($script:MODULE['HELPERS_DIR'])\*.ps1" | % { . $_.FullName } +Get-ChildItem "$($script:MODULE['PUBLIC_DIR'])\*.ps1" | % { . $_.FullName } +Get-ChildItem "$($script:MODULE['PRIVATE_DIR'])\*.ps1" | % { . $_.FullName } +Get-ChildItem "$($script:MODULE['HELPERS_DIR'])\*.ps1" | % { . $_.FullName } # Export Public functions Export-ModuleMember -Function (Get-ChildItem "$($script:MODULE['PUBLIC_DIR'])\*.ps1" | Select-Object -ExpandProperty BaseName)