Skip to content

Instantly share code, notes, and snippets.

@1RedOne
Created September 18, 2017 18:11
Show Gist options
  • Select an option

  • Save 1RedOne/e48598f9faa328f97d99bb9fca2e98ac to your computer and use it in GitHub Desktop.

Select an option

Save 1RedOne/e48598f9faa328f97d99bb9fca2e98ac to your computer and use it in GitHub Desktop.
LazyModule.psm1
# Use your module PSM1 to import functions, then run one or two if needed
# Based on Warren Frame's Plaster module format
#
#Get public and private function definition files.
$PublicFunction = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -Exclude *tests* -ErrorAction SilentlyContinue )
$PrivateFunction = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -Exclude *tests* -ErrorAction SilentlyContinue )
#Dot source the files
Foreach($import in @($PublicFunction + $PrivateFunction))
{
"importing $import"
Try
{
. $import.fullname
}
Catch
{
Write-Error -Message "Failed to import function $($import.fullname): $_"
}
}
#region AW Device Type
Update-TypeData -PrependPath $PSScriptRoot\Types.ps1xml -Verbose
Update-FormatData -PrependPath $PSScriptRoot\Format.PSAirwatch.ps1xml -Verbose
#endregion
Export-ModuleMember -Function $PublicFunction.Basename
Connect-AWAccount -Verbose
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment