The inclusion of one ps1 to another?

Someone how to connect the files without the package installation?
The universal, which did
.(Join-Path -Path (Split-Path $script:MyInvocation.MyCommand.Path-Parent) -ChildPath ".\any.ps1")

I would like
.(Join-Path -Path (Split-Path $script:MyInvocation.MyCommand.Path-Parent) -ChildPath ".\PS.Get-Include.ps1")
Get-Include ".\any1.ps1"
...
Get-Include ".\any2.ps1"

but the scope apparently suffers from this.
Maybe there is some default package for this behavior or what?
April 19th 20 at 12:16
1 answer
April 19th 20 at 12:18
Solution
Frequently used functions can be folded into a module
An example of the structure:
MyUtils/
MyUtils.psd1
MyUtils.psm1
functions/
Get-Something.ps1
 Get-SomethingOther.ps1

The Contents Of MyUtils.psd1, the minimum option. only filled fields
@{
 ModuleVersion = '1.0'
 GUID = '72d739dd-bddf-4d7c-a358-1a40e2ff961d'
 Description = 'MyUtils module'
 NestedModules = @('MyUtils.psm1')
}

A Guid must be generated using [guid]::NewGuid()
The Contents Of MyUtils.psm1
Try {
 Get-ChildItem "$PSScriptRoot\functions\*.ps1" -Exclude *.tests.ps1 *profile.ps1 |
 ForEach-Object {
 $Function = $_.Name
 . $_.FullName
}
} Catch {
 Write-Warning ("{0}: {1}" -f $Function,$_.Exception.Message)
Continue
}

Sample content one of the functions
function Get-Something {
param(
$parameter
)
 Write-Host "I'm Get-Something with $parameter"
}


All additional functions can be developed separately and then just placed into the folder of the MyUtils\functions.
and they will be able to connect to the module when it is reloading with powershell
or using Import-Module MyUtils -Force

The module itself is in the form of a folder, you can carry by simply copying one of the locations specified via $env:PSModulePath
thank you - shanelle47 commented on April 19th 20 at 12:21

Find more questions by tags PowerShell