2014-11-13 1 views
5

배포 스크립트를 실행하는 Octopus Tentacle이 있습니다. 촉수가 LocalSystem 계정으로 실행 중입니다.Octopus Deploy의 대체 자격 증명을 사용하는 Powershell 작업

스크립트 내에서 일부 보관 비트를 제외하고 필요한 모든 것을 거의 할 수 있습니다. 아카이브는 네트워크 공유에 있기 때문에 다른 도메인 자격 증명으로 완료해야합니다.

실망이 코드가 아래에 로컬로 작동하지만, 촉수를 실행하면 오류 여기

----------------------------------------------------[ Backup Nupkg ]---------------------------------------------------- Storing a backup version of GeoSphere.1.2.1.1722.nupkg for the Development environment
Error 09:24:32 [localhost] There is an error launching the
background process. Error Error 09:24:32 reported: Access is
denied. Error 09:24:32 At
C:\Octopus\Deployments\Development\GeoSphere\1.2.1.1722\deploy.ps1:121
Error 09:24:32 char:1 Error 09:24:32
+ Receive-Job $job Error 09:24:32
+ ~~~~~~~~~~~~~~~~ Error 09:24:32
+ CategoryInfo : OpenError: (localhost:String) [], PSRemotingTran Error 09:24:32 sportException Error 09:24:32
+ FullyQualifiedErrorId : -2147467259,PSSessionStateBroken Info 09:24:32 HasMoreData : False StatusMessage : Location :
localhost Command : Import-Module $args[3]
Backup-Nupkg $args[0] $args[1] $args[2]
JobStateInfo : Failed Finished : System.Threading.ManualResetEvent InstanceId :
0c031592-4c2a-4f8b-b014-a5ba79be09f7 Id : 1 Name :
Job1 ChildJobs : {Job2} PSBeginTime : 13/11/2014 9:24:30 AM
PSEndTime : 13/11/2014 9:24:31 AM PSJobTypeName : BackgroundJob
Output : {} Error : {} Progress : {} Verbose
: {} Debug : {} Warning : {} State : Failed
Fatal 09:24:32 PowerShell script returned a non-zero exit code: 1
Tentacle version 2.5.11.614

실패의 코드

$pwd = convertto-securestring "[PASSWORD]" -asplaintext -force 
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist "[DOMAIN\USER]",$pwd 
$packageName = "GeoSphere.$Version.nupkg" 
$backupPath = $($es.backupPath) 
$artifactsPath = $($es.artifactsPath) 
$job = Start-Job -ScriptBlock { 
    Import-Module $args[3] 
    Backup-Nupkg $args[0] $args[1] $args[2] 
} -ArgumentList @($packageName,$backupPath,$artifactsPath,"$currentDir\modules\ApplicationUtilities") -Credential $cred 

Wait-Job $Job 
Receive-Job $job 

을 여기 있다는 것입니다 ApplicationUtilities 모듈

function Backup-Nupkg{ 
    param(
     [parameter(Mandatory=$true,position=0)] [string] $packageName, 
     [parameter(Mandatory=$true,position=1)] [string] $backupPath, 
     [parameter(Mandatory=$true,position=2)] [string] $artifactsPath 
    ) 

    if(!(Test-Path $($backupPath))) { 
     md $($backupPath) 
    } else { 
     Remove-Item "$($backupPath)\*" -recurse -Force 
    } 

    Copy-Item $artifactsPath\$packageName $backupPath 
} 

Export-ModuleMember Backup-Nupkg 

도망 치기위한 마술 트릭이란 무엇입니까? 촉수는 현지에서하는 것처럼?

+0

또한 촉탁 서비스가 지정된 사용자로 실행되도록 시도했지만 그 다음 다른 렌치를 해당 구성에 던지게하는 IIS 구성 문제가 발생했습니다. 이러한 잘못된 인증 문제는 고통 스럽습니다. –

답변

6

행운없이 같은 일을 시도했지만 다른 사용자로 작업을 시작할 수없는 것 같습니다. 이 비슷한 질문에서 르블랑 대신 WinRM이와 Invoke-Command를 사용하여 종료 :

run script block as a specific user with Powershell

(I이 생각하지 않습니다되어 아무것도 문어의 특정을 - 문제가 시스템이 시작할 수있는에 문제가 더 많은 것 같다 프로세스가 다른 사용자 또는 Start-Job (SYSTEM 또는 아마도 양쪽 모두)

+0

폴 감사합니다. 관리자 자격 증명으로 서비스 계정을 하나로 변경했습니다. 거기에서 나는 새로운 직업을 시작할 필요조차없이 사본을 할 수있었습니다. –