Windows Registry key is not reading in my Octopus Job

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

Second Approach

$RegPaths = @(“HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings”)

$ProdProp = @{
Path = $RegPaths
Name = @(‘ProxyOverride’)
ErrorAction = “SilentlyContinue”
}

$Product = Get-ItemPropertyValue @ProdProp

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 .

That would be great if anyone can assist.

But I am successfully run locally this one on my Octopus target agent system

Hi Pokuri.rk,

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?

Best Regards,

Charles

Thanks for your response, How do I check the Octopus user on Octopus Target system

Hi Pokuri.rk,

Thank you for your message.

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.

Best Regards,

Charles

Thank you Charles.hague,

I see Octopus tentacle is running with local service account.
Can i give network service account and and run the job ?

image

Thank you, it is working with octopus user but one more issue s coming but not sure what went wrong .

The error details are

google.com;foo.com;

October 29th 2020 23:30:26

Error

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

October 29th 2020 23:30:26

Error

  • $hostname_vars = OctopusVar(“proxy”)

here is my code

$RegPaths = @(“HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings”)

$ProdProp = @{
Path = $RegPaths
Name = @(‘ProxyOverride’)
ErrorAction = “SilentlyContinue”
}

$Product = Get-ItemPropertyValue @ProdProp

Write-output “$Product”

#$goodProxies = @(‘google.com’,‘domain.com’,‘foo.com’)
#$proxy_vars = OctopusVar(‘proxy’)

$hostname_vars = OctopusVar(‘proxy’)

====
Please can you advise

Hi Pokuri.rk,

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?

Please let me know if you have any questions.

Best Regards,

Charles

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.