Advanced function - store function output in global variable

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Rob Simmers Rob Simmers 1 week, 5 days ago.

  • Author
    Posts
  • #58839
    Profile photo of Bojan Zivkovic
    Bojan Zivkovic
    Participant

    Hi, I have myriad advanced functions, some of which heavily rely on the "main" advanced function which reads a .properties file and extracts some values by using regular expressions. I implemented the "main" advanced function to collect values from .properties file and return object with these values as properties.

    Is there any way to call this main advanced function only once and store its output (custom object in my case) in global variable thus I could reference to needed value in other functions by variable.nameofproperty instead of calling function again and again from other functions.

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

  • #58861
    Profile photo of Rob Simmers
    Rob Simmers
    Participant

    I asked a similar question regarding session information persisting versus having to call the same function over and over. Take a look at Warren's response and InfoBlox implmentation:

You must be logged in to reply to this topic.