Skip to content

Instantly share code, notes, and snippets.

@MarioBinder
Created September 16, 2019 05:40
Show Gist options
  • Select an option

  • Save MarioBinder/83e362b759a2437dd7ee99cbf7e32993 to your computer and use it in GitHub Desktop.

Select an option

Save MarioBinder/83e362b759a2437dd7ee99cbf7e32993 to your computer and use it in GitHub Desktop.
Windows Service / Job Deploy #teamcity
$server = "%INT_Jobserver_Name%"
$username = "%INT_Jobserver_Username%"
$password = "%INT_Jobserver_Password%" | ConvertTo-SecureString -AsPlainText -Force
$creds = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$session = New-PSSession -ComputerName $server -Credential $creds
Enter-PSSession $session
Invoke-Command {Stop-Service "Softcrafts.Service.Name"} -Session $session
Start-Sleep -s 30
Copy-Item -Path "Softcrafts.Service.Name\bin\%BuildConfiguration%\**\" -Destination "%INT_Jobserver_Softcrafts_Service_Rootpath%Softcrafts.Service.Name" –Recurse -ToSession $session
Start-Sleep -s 30
Invoke-Command {Start-Service "Softcrafts.Service.Name"} -Session $session
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment