Author Posts

November 6, 2017 at 12:32 pm

Hi, I wrote more than 20 advanced functions to automate installation/configuration process of document management platform (OpenText Documentum xCP). One of them is "input" function for many others since it returns an object containing 3 crucial properties (docbroker host name, docbase name and global registry password). Can I call this "main" function only once, store returned object into global variable and then just use property of that variable in other functions?

i.e. $global:dfc = Get-DFCParameter -xCP1ComputerName VMContentServer
from some other function:
$Docbroker = $dfc.docbrokerhostname
$Docbase = $dfc.docbasename
$GlobalRegistryPassword = $dfc.globalregistrypassword

Note: I posted similar question last year but no one answered. More luck this time I hope.

November 6, 2017 at 2:40 pm

One answer would be to create your own Registry hive and set keys in there.

November 6, 2017 at 2:45 pm

Then I found this on the web: Use PowerShell to Persist Environment Variables

Use PowerShell to Persist Environment Variables


cut& paste from there below:

### Use the variable syntax to create a new environment variable
$env:FirstName = 'Trevor'
### Use the built-in env: PSDrive
New-Item -Path env:\LastName -Value Sullivan
### Set an environment variable using the System.Environment .NET class
[System.Environment]::SetEnvironmentVariable('DOCKER_HOST', 'docker.artofshell.com')