Link to home
Start Free TrialLog in
Avatar of janhoedt
janhoedt

asked on

Powershell Studio, make a project not environment dependant?

Hi,

I have a Powershell Studio project, tool which is linked to the current domain.
Variables are hardcoded in the tool, f.e. $SCCMServer = oursccmserver.ourdomain.com, $RDSServer = ourrdsserver.ourdomain.com
I'd like to use the tool in another domain so need to extract all the variables and would like to put them in a textfile.
So that file would contain:
#SCCM server, fill in here
$SCCMServer =
etc

To give you an example, vcheck works this way:
https://github.com/alanrenouf/vCheck-vSphere
But I wonder howto transfer my current script the least painful way (kind of search and replace way)

How to achieve this the best way?
Please advise.
J.
ASKER CERTIFIED SOLUTION
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of janhoedt
janhoedt

ASKER

Thanks for your input but I wonder what the advantage of this method is above the one used in
https://github.com/alanrenouf/vCheck-vSphere 

The file GlobalVariables.ps1 contains f.e.
$SMTPSRV = "mysmtpserver.mydomain.local"

Then in the script:
$GlobalVariables = $ScriptPath + "\GlobalVariables.ps1"
Get-Content $GlobalVariables
. $GlobalVariables
that means you have to go through 2 files later on and then match one file to the other.. This makes it very hard to maintain
Why would you need to go through 2 files?  F.e. you change $smtpserver = new server in one file, that s it, right?