Powershell: keeping all variables in 1 globalvariables.ps1, then load in profile ... but howto exchange these scripts then? RRS feed

  • Question

  • Hi,

    I'd like to keep all my variables in a GlobalVariables.ps1 which I load in my profile.
    All my scripts would then just use $SCCMServer or $SMTPServer instead of full name.

    However, this limits the exchange of my scripts, since the scripts won't have the GlobalVariables.ps1.
    I could copy GlobalVariables.ps1 to each script I exchange and refer in it via $psscriptroot\globalvariables.ps1 but then I'd need to refer in each of my scripts to this $psscriptroot whereas it is already in my globalvariables.ps1 which is loaded in my profile.
    How to address this?

    Please advise.

    Jan Hoedt

    Monday, October 30, 2017 5:23 PM


  • You would have to have each user set up their profile or just specify the script n each run.  There is no other magic available.


    • Marked as answer by janhoedt Thursday, November 2, 2017 9:22 AM
    Monday, October 30, 2017 5:31 PM