Powershell - Invoke-sqlcmd - runas admin

I’m running a PowerShell script from a Project on the Octopus server. The script shall recreate a database on the DB-server.
Trying to install it via another server (INT-server); this server have all the sqlserver files needed. Like the pssnapins and psprovider)

So I’m sending the Artifacts to the INT-server, and run the script from this server.

The scripts fails; not able to use the user account that I have tried to specify. Ref page: http://docs.octopusdeploy.com/display/OD/Running+Tentacle+under+a+specific+user+account+for+use+in+Powershell

Error message:
Drop and (re)create database
Invoke-Sqlcmd : Login failed for user ‘UTVIKLING\TVRA-WIN-ES-041$’.

How do I manage to run the script With the correct user

TVRA-WIN-ES-041 is the server name where I run the PowerShell script from

Hi Kristel,

Thanks for getting in touch and sorry to hear you’re having trouble with the deployment. To help with troubleshooting, could I just confirm whether ‘UTVIKLING\TVRA-WIN-ES-041$’ is the account you specified the Tentacle service to run as on INT-server? From the error provided it looks like that is the account the service is running as and that account doesn’t have a login in SQL Server, and I just want to make sure I understand what the correct account is.

My estimate at this point would be that if it’s not the correct account then assigning the user to the Tentacle’s Windows service mustn’t have saved correctly. If it is the correct account then it’s likely that the login hasn’t been created correctly in SQL Server.

Sorry I don’t have something more definitive at this point, but if you could verify those details then I’ll assist further in whatever way I can.

Shannon

Hi Sharron

No, TVRA-WIN-ES-041 is the server name. So I don’t understand why he use this
To run the tentacle I use the build service user. That also have the rights to recreate DB om the DB-server

I use the svcp360teamci service user on all the Tentacle services, and also on the Octopus server and the DB-server
Is there something I do wrong when defining the Tentacles?

From the Octopus server:
[cid:image004.jpg@01D24EF5.028880A0]

From the INT-Server:

[cid:image005.jpg@01D24EF5.028880A0]

Kristel

Fra: Shannon Lewis [mailto:tender2+d67d225756@tenderapp.com]
Sendt: 5. desember 2016 11:35
Til: Kristel Flindt Aune
Emne: Re: Powershell - Invoke-sqlcmd - runas admin [Questions #10038]

Hi Kristel,

The details on the services look ok. Just to check, the services have been restarted since the account details were changed?

Given that those details look ok, would you be able to attach the raw log for the deployment so we can see what detail is in there? If you’re not sure on how to get that, there’s some information in our documentation.

You can sanitise the file if there is information in there you don’t want shared (what I’m mainly looking for is the CurrentUser information), and feel free to mark this discussion as private if you want to.

Shannon

Hi shannon

I had restarted the tentacles. But not the
Octopus service on the Octopus server. now its seams to work. will test it more tomorrow
Thanks!
Kristel

Sendt fra min Samsung-enhet

-------- Opprinnelig melding --------
Fra: Shannon Lewis tender2+d67d225756@tenderapp.com
Dato: 06.12.2016 05.46 (GMT+01:00)
Til: Kristel Flindt Aune Kristel.Flindt.Aune@helsedir.no
Emne: Re: Powershell - Invoke-sqlcmd - runas admin [Questions #10038]