Hi, I need the list of HostNames associated with target, how do I do that this is critical for me to interact with other systems.
Thanks for getting in touch. If you want to access the host name from a script step, you can just use some PowerShell
$env:computername and store it as a local variable and use it in that script block, or use output variables to use it later.
Set-OctopusVariable -name “CurrentHostName” -value $env:computername
There’s a great walk through of output variables on our blog. Or if it was a once off retrieval you could use the Script Console via the Tasks area to run a similar set of PowerShell code to get the host names.
If you’re talking about DNS host names, then it’s about how it’s configured on your DNS server, you could correlated them by IP address by using PowerShell to get the IP address of the targets and look it up that way.
I do not need an individual server, I need all the servers which are getting targeted via deployment.
Do you have multiple projects? If so then my first suggestion as it’ll be project specific.
Also we still weren’t clear if you meant DNS hostname or just machine hostname?
Ok let me try again -
I want to know Host Names (DNS HostNames) of all machines under 1 role.
DNS isn’t necessarily something managed by Octopus, you could try making use of
If you wanted to just do it per role, you can use the Scrip Console, see the documentation here: https://octopus.com/docs/administration/script-console#using-the-script-console, to run the code you write to determine the DNS host name, the code will be executed on the target.