Import-PSScriptFile.ps1
<#PSScriptInfo
.VERSION 1.0 .GUID be10708b-42f1-4afe-9521-a8303f123fd8 .AUTHOR atorrest .COMPANYNAME atorrest .COPYRIGHT atorrest .DESCRIPTION Import all ps1 files to the current session using the 'dot sourcing operator' #> function Import-PSScriptFile { <# .SYNOPSIS Import all ps1 files to the current session. .PARAMETER LiteralPath A path to one location. Default value $PSScriptRoot. .PARAMETER Filter A filter format. Wildcards are permitted. Default value '*.ps1' .EXAMPLE PS C:\> Import-PSScriptFile Import all ps1 files in the current folder. .EXAMPLE PS C:\> Import-PSScriptFile -LiteralPath 'C:\Temp' -Filter 'Functions/*.ps1' Import all ps1 files in C:\Temp\Functions folder. #> [CmdletBinding()] param ( [Parameter(ValueFromPipeline)] [ValidateNotNullOrEmpty()] [string] $LiteralPath = "$PSScriptRoot", [ValidateNotNullOrEmpty()] [string] $Filter = '*.ps1' ) Get-ChildItem -LiteralPath $LiteralPath -Filter $Filter -File | Select-Object -ExpandProperty FullName | ForEach-Object { . $_ } } |