Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How to import variable values?

Reply
 
Old 03-18-2009   #1 (permalink)
C S S


 
 

How to import variable values?

Is there a preferred or recommended way to have an .ini-like file for
Powershell? In a configuration script that I'm writing, I want to be able to
use it at two different locations, which require different values for various
settings.

I was thinking of using the & operator with a separate .ps1 script that
initialized all of the variables to the initial values I wanted, but would an
XML or INI file loaded into a hash-table be more appropriate/best-practice?

Ideally, it would be nice to encrypt the variable files so that I could
maintain them in the same common directory, and specify either (along with
the respective password) from the command line, while at the same time
preventing prying eyes from opening and viewing the contents of those
variables.



My System SpecsSystem Spec
Old 03-18-2009   #2 (permalink)
Rob Campbell


 
 

RE: How to import variable values?

I don't know if it's "recommended" or not, but I've done pretty much what
you're asking using export-clixml. If data needs to be loaded into a hash
table, I just construct it as a hash table, and export that. When I need it
back, I just do an import-clixml, and I have my hash table back. As far as
keeping it away from "prying eyes", that's what NTFS permissions are for,
IMHO.

"C S S" wrote:
Quote:

> Is there a preferred or recommended way to have an .ini-like file for
> Powershell? In a configuration script that I'm writing, I want to be able to
> use it at two different locations, which require different values for various
> settings.
>
> I was thinking of using the & operator with a separate .ps1 script that
> initialized all of the variables to the initial values I wanted, but would an
> XML or INI file loaded into a hash-table be more appropriate/best-practice?
>
> Ideally, it would be nice to encrypt the variable files so that I could
> maintain them in the same common directory, and specify either (along with
> the respective password) from the command line, while at the same time
> preventing prying eyes from opening and viewing the contents of those
> variables.
>
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
values VB Script
Re: how to change xml values PowerShell
Import-CSV from Web/Variable PowerShell
how to assign values to array and how to create array via variable PowerShell
How can I ensure that a variable is a built-in powershell variable? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46