Hi, I am reading registry value from registry subkey in my job and my deployment step is just names as “Run a Script” using PowerShell . In my deployment step I have mentioned the below code.
$regVal = "Get-ItemPropertyValue -Path ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings’ -Name ProxyOverride
and ProxyOverride value is in registry subkey is foo.com;domain.com.
But when i run the job it is getting failed due to the below error and both of approach are not working
Here is the failed log
InvalidArgument: Property ProxyOverride does not exist at path HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings.
October 29th 2020 17:18:03Error
At C:\Octopus\Work\20201029114759-4844-13\Script.ps1:54 char:14
October 29th 2020 17:18:03Error
$Product = Get-ItemPropertyValue @ProdProp
October 29th 2020 17:18:03Error
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
October 29th 2020 17:18:03Error
at , C:\Octopus\Work\20201029114759-4844-13\Script.ps1: line 54
October 29th 2020 17:18:03Error
at , C:\Octopus\Work\20201029114759-4844-13\Bootstrap.Script.ps1: line 1508 .
Thank you for reaching out to us with your query about reading a registry key.
It looks like your script references the HKEY_CURRENT_USER root key. This key will have different contents depending on which user is logged in and executing the script. In this case, it might be that the user you are logging in as to test is different than the user that Octopus is running as.
Can you please try logging in as the Octopus user and testing the script manually?
You can find out what machines the script is failing on by checking the task log which will show the machine name at the top of the segment. Once you’ve determined that you can log on to the machine in question and identify which user account the Tentacle is running as. You can then attempt to log on as that user if possible and try to run the script manually. That will hopefully confirm whether or not the script can run.
I hope this is helpful. Please let me know if you have any questions.
ObjectNotFound: The term ‘OctopusVar’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
October 29th 2020 23:30:26
Error
At C:\Octopus\Work\20201029180020-4866-3\Script.ps1:62 char:19
Thank you for getting back to us with your update.
I don’t recognise OctopusVar as a function we provide, so it sounds like it might be something specific to your Powershell script. Are you able to confirm where it is defined and what it is supposed to do?
It looks like proxy might be referencing an Octopus Deploy variable. If that is the case, then could you please try changing it to $proxy instead?