Im not sure what is not working for you. What is the function your calling
suppose to do? Do you set $ErrorActionPreference anywhere?
Here is my test... I have two scripts. Testdotsource.ps1 and bleh.ps1
== testdotsource.ps1 ===
param(
$computername = $null,
[switch]$param1,
[switch]$param2,
[switch]$param3
)
.. t:\pathtoscript\bleh.ps1
foo1
foo2
foo3
===================
===== bleh.ps1 ========
function foo1{"foo1 worked"}
function foo2{"foo2 worked"}
function foo3{"foo3 worked"}
====================
122# T:\Scripts\testdotsource.ps1
foo1 worked
foo2 worked
foo3 worked
"Nicopilami" <n.chaussard@gmail.com> wrote in message
news:1187630734.115009.195920@g4g2000hsf.googlegroups.com...
On 20 août, 17:02, "Brandon Shell" <tshell.m...@gmail.com> wrote:
> Param must be at the begining and there is no requirement for DoT sourcing
> that I know of.
>
> Your Second example worked for me except you had three [switch]$param1
> instead of 1/2/3.
>
> param(
> $ccomputername = $null,
> [switch]$param1,
> [switch]$param2,
> [switch]$param3
> )
> . $pwd\bleh.ps1
>
> What is the problem you are having? Error?
>
> "Nicopilami" <n.chauss...@gmail.com> wrote in message
>
> news:1187621550.303710.233370@r34g2000hsd.googlegroups.com...
>
>
>
> > hello, i would like to use some fonctions of a dot-sourced file and
> > get all the parameters setted in the command line at the same time;
>
> > how to make the following lines exist at the same time ?
> > i've read that every dotsourced reference had to be located at the
> > first line of the script, and the same things for the param command.
>
> > For this reason, the following scriptblock doesn't work because param
> > isn't at the first line...
>
> > . ./functions.ps1
> > param(
> > $computername=$null,
> > [switch]$param1,
> > [switch]$param1,
> > [switch]$param1
> > )
>
> > and the following scriptblock doesn't work because the dotsourcing is
> > not at the first line...
>
> > param(
> > $computername=$null,
> > [switch]$param1,
> > [switch]$param1,
> > [switch]$param1
> > )
> > . ./functions.ps1
>
> > how should i do ???
>
> > Bye
> > Nico- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -
the dotsourced file contains a function, and when i call this function
from the first script after i have dotsourced the file, nothing happens. :'(
(three time of $param1 is a bit too much, actually, it was $param1, 2,
3 ...but i forgot to change it when i changed and pasted the code
here...)
how could i do for making it work ?