Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Can I use a DATA Section contained in an external file? e.g. in a psm1 module file.

$
0
0

In Powershell v2 I am trying to use DATA Sections contained in a psm1 file.

I can get it to work if I use the DATA Section within the main ps1 Script file:

## Code
Write-Host $testDataSection
## Code
DATA testDataSection {"This is a Test"}

But am I able to put the DATA Section in a psm1 File (or even osd1 file), and still use the Variable in a calling ps1 script? When I try this using ImportModule -name 'moduleContainingDATA.psm1',  "Write-Host $testDataSection" doesn't output anything.

about_Data_Sections says Data Sections "lets you have separate string resource files for text, such as error messages and Help strings". I'm trying to do something similar with storing SQL Statements in an external file.


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>