I am configuring my windows service in a deployment step and we run the service in a custom account. When it asks for the custom account name it requires the domain of the user. As this is a user local to the machine, how can I get the domain automatically?
I don’t want to create it as a variable as the deployment target might change, the user name will stay the same but the domain will change.
Thanks for reaching out. There’s no easy way to get the domain automatically like you are asking. The only way I can think of is a bit too complicated and goes like this:
Have a script step named “Get Domain” that gets the domain of your machine and saves it to an output variable called “Domain” that’ll be used by the step that creates the app pool. Script should be like this:
$domain = (gwmi WIN32_ComputerSystem).Domain
write-host "creating variable called 'domain' with value: $domain"
Set-OctopusVariable -name "Domain" -value "$domain"
In the step where you define the user for your App Pool, use the output variable you created like this: $OctopusParameters["Octopus.Action[Get Domain].Output.Domain"]
Thanks for coming back to me. That’s what I have been doing so far, I was hoping there was an easier way.
That’s great though, I will leave it working as is.