Running into a problem that I'm not sure how to solve, and haven't been able
to find anything in the documentation to help. I suspect it's a issue with
the path but not sure how to get the path of a module from within the module
so I can find a dot source a file in the same directory.
I have a module which provides a trivial interface for lookup email lists.
I want to keep the actual email addresses in a seperate .ps1 file from the
code so that I can easily deploy this script to development and production
and just swap out the emails.ps1 file
So there are two files, Emails.ps1 and EmailList.psm1.
Here's EmailList.psm1:
# Emails.ps1 contains a bunch of variables with email lists.
.. Emails.ps1
$emails_TO_lists = @{
'JOB'=$JOB_LIST;
};
Function Get-EmailTo($key)
{
<#
..SYNOPSIS
return the TO emails for a key
..EXAMPLE
Get-EmailTo "JOB"
#>
return $emails_TO_lists[$key]
}
The error I get from importing at the command line:
mwarren@V-WS-IS-51:C:\dev\trading\SharedScripts$ import-module
..\Shared\Email\EmailList.psm1 -Force
The term 'Emails.ps1' is not recognized as the name of a cmdlet, function,
script file, or operable program. Check the spelling of the name, or if a
path was included, verify that the path is correct and tr
y again.
At C:\dev\trading\SharedScripts\Shared\Email\EmailList.psm1:8 char:2
+ . <<<< Emails.ps1
+ CategoryInfo : ObjectNotFound: (Emails.ps1:String) [],
CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
|
|
0
|
|
|
|
Reply
|
Utf
|
3/29/2010 9:13:01 PM |
|
RnJvbSBhYm91dF9BdXRvbWF0aWNfVmFyaWFibGVzDQoNCiAgICRQU1NjcmlwdFJvb3QNCiAgICAg
IENvbnRhaW5zIHRoZSBkaXJlY3RvcnkgZnJvbSB3aGljaCB0aGUgc2NyaXB0IG1vZHVsZSBpcyBi
ZWluZyBleGVjdXRlZC4NCiAgICAgIFRoaXMgdmFyaWFibGUgYWxsb3dzIHNjcmlwdHMgdG8gdXNl
IHRoZSBtb2R1bGUgcGF0aCB0byBhY2Nlc3Mgb3RoZXINCiAgICAgIHJlc291cmNlcy4NCg0KLS0g
DQpSb2JlcnQNCmh0dHA6Ly9yb2JlcnRyb2JlbG8uc3BhY2VzLmxpdmUuY29tLw==
|
|
0
|
|
|
|
Reply
|
Robert
|
3/29/2010 9:46:50 PM
|
|
That helped.
I just changed the dot source to:
.. $PSScriptRoot\Emails.ps1
"Robert Robelo" wrote:
> From about_Automatic_Variables
>
> $PSScriptRoot
> Contains the directory from which the script module is being
> executed.
> This variable allows scripts to use the module path to access other
> resources.
>
> --
> Robert
> http://robertrobelo.spaces.live.com/
>
|
|
0
|
|
|
|
Reply
|
Utf
|
3/29/2010 10:39:01 PM
|
|