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.co m, $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.
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.co
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
ASKER
Why would you need to go through 2 files? F.e. you change $smtpserver = new server in one file, that s it, right?
ASKER
https://github.com/alanrenouf/vCheck-vSphere
The file GlobalVariables.ps1 contains f.e.
$SMTPSRV = "mysmtpserver.mydomain.loc
Then in the script:
$GlobalVariables = $ScriptPath + "\GlobalVariables.ps1"
Get-Content $GlobalVariables
. $GlobalVariables