Answer the question
In order to leave comments, you need to log in
Turning one ps1 into another?
Who connects files without installing packages?
The most versatile thing I've done is
.(Join-Path -Path (Split-Path $script:MyInvocation.MyCommand.Path -Parent) -ChildPath ".\any.ps1")
.(Join-Path -Path (Split-Path $script:MyInvocation.MyCommand.Path -Parent) -ChildPath ".\PS.Get-Include.ps1")
Get-Include ".\any1.ps1"
...
Get-Include ".\any2.ps1"
Answer the question
In order to leave comments, you need to log in
Frequently used functions can be folded into a module
Structure example:
MyUtils/
MyUtils.psd1
MyUtils.psm1
functions/
Get-Something.ps1
Get-SomethingOther.ps1
@{
ModuleVersion = '1.0'
GUID = '72d739dd-bddf-4d7c-a358-1a40e2ff961d'
Description = 'MyUtils module'
NestedModules = @('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
}
function Get-Something {
param(
$parameter
)
Write-Host "I'm Get-Something with $parameter"
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question