![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Dot sourcing multiple code files Hi am new to PowerShell scripting/programming. I am trying to created a couple of "libraries" from which code can be reused. I have created two ..ps1 files one with functions that perform some general tasks and another that contains some variables that contain non-changing data. I a specific script that I create I am able to dot source the file with the functions. But when I try and another external file (the one with variables) I loose the functionality of the first (function) file, and cannot access the functionality from the first second file that I dot sourced. Is there a way I can create multiple libraries that can simultaneously be accessed by one or more scripts, with out having to incorporate these functionality in the libraries into the Windows PowerShell profile (config file). Let me know if you need more info to clarify my problem and the solution I'm seeking. Thanks |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Dot sourcing multiple code files "henry Macoy" <henry.macoy@xxxxxx> wrote in message news:%23rDWxI%23AIHA.3780@xxxxxx Quote: > Hi am new to PowerShell scripting/programming. I am trying to created a > couple of "libraries" from which code can be reused. I have created two > .ps1 files one with functions that perform some general tasks and another > that contains some variables that contain non-changing data. I a specific > script that I create I am able to dot source the file with the functions. > But when I try and another external file (the one with variables) I loose > the functionality of the first (function) file, and cannot access the > functionality from the first second file that I dot sourced. Is there a > way I can create multiple libraries that can simultaneously be accessed by > one or more scripts, with out having to incorporate these functionality in > the libraries into the Windows PowerShell profile (config file). Let me > know if you need more info to clarify my problem and the solution I'm > seeking. > > Thanks You can dot source more than one file within a script eg .. "C:\Users\Me\MyFunctions.ps1" .. "C:\Users\Me\MyVariables.ps1" or you're perhaps encountering a scope issue Get-Help about_Scope Otherwise you may wish to rephrase the question. -- Jon |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Dot sourcing multiple code files I would recommend reading the profile that comes with PSCX. It is pretty clear and it does exactly what you want. "Jon" <Email_Address@xxxxxx> wrote in message news:e2I4%23A$AIHA.1212@xxxxxx Quote: > > "henry Macoy" <henry.macoy@xxxxxx> wrote in message > news:%23rDWxI%23AIHA.3780@xxxxxx Quote: >> Hi am new to PowerShell scripting/programming. I am trying to created a >> couple of "libraries" from which code can be reused. I have created two >> .ps1 files one with functions that perform some general tasks and another >> that contains some variables that contain non-changing data. I a specific >> script that I create I am able to dot source the file with the functions. >> But when I try and another external file (the one with variables) I loose >> the functionality of the first (function) file, and cannot access the >> functionality from the first second file that I dot sourced. Is there a >> way I can create multiple libraries that can simultaneously be accessed >> by one or more scripts, with out having to incorporate these >> functionality in the libraries into the Windows PowerShell profile >> (config file). Let me know if you need more info to clarify my problem >> and the solution I'm seeking. >> >> Thanks > > > > You can dot source more than one file within a script eg > > . "C:\Users\Me\MyFunctions.ps1" > . "C:\Users\Me\MyVariables.ps1" > > or you're perhaps encountering a scope issue > > Get-Help about_Scope > > > Otherwise you may wish to rephrase the question. > > > -- > Jon > > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: Dot sourcing multiple code files henry Macoy wrote: Quote: > sourced. Is there a way I can create multiple libraries that can > simultaneously be accessed by one or more scripts, with out having to > incorporate these functionality in the libraries into the Windows > PowerShell profile (config file). Let me know if you need more info to > clarify my problem and the solution I'm seeking. what's going wrong in your case. -- Hal Rottenberg Blog: http://halr9000.com Webmaster, Psi (http://psi-im.org) Co-host, PowerScripting Podcast (http://powerscripting.net) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Dot-sourcing and scope | PowerShell | |||
| Newbie question: replace multiple strings in multiple text files | VB Script | |||
| does .dot-sourcing a set of functions compile these into MSIL? | PowerShell | |||
| Vista Code = Multiple Problems | Vista General | |||
| sourcing a file in a script | PowerShell | |||