My DSC script is setting JAVA_HOME via a custom module, after successful JAVA installation.
I'm then trying to retrieve the updated JAVA home using the following line in a Script resource -
SetScript = "[Environment]::SetEnvironmentVariable('JAVA_HOME',[System.Environment]::GetEnvironmentVariable('JAVA_HOME','Machine'))"
I can see the verbose log stating the resource is executed. However, after the script finishes my console is still holding on to the previous JAVA_HOME.
The issue I have with this is, my script (further down) needs to call a batch file that uses JAVA_HOME but because the session is passing the wrong value it is failing with "System can't find the path specified".
Can anyone please help with some solution to overcome this problem?
Disclaimer: I'm very very new to powershell. Please explain in detail please.