Windows EC2Launch v2 - not able to executeScript as admin

0

I'm trying to execute a startup script on a Windows EC2 instance (g4ad.large). I'm using the agent-config.yml configuration file for EC2Launch v2, and trying to use the executeScript task.

Here's my entire agent-config.yml:

version: 1.0
config:
- stage: boot
  tasks:
  - task: extendRootPartition
- stage: preReady
  tasks:
  - task: activateWindows
    inputs:
      activation:
        type: amazon
  - task: setDnsSuffix
    inputs:
      suffixes:
      - $REGION.ec2-utilities.amazonaws.com
  - task: setAdminAccount
    inputs:
      password:
        type: random
  - task: setWallpaper
    inputs:
      path: C:\ProgramData\Amazon\EC2Launch\wallpaper\Ec2Wallpaper.jpg
      attributes:
      - hostName
      - instanceId
      - privateIpAddress
      - publicIpAddress
      - instanceSize
      - availabilityZone
      - architecture
      - memory
      - network
- stage: postReady
  tasks:
  - task: startSsm
  - task: executeScript
    inputs:
    - frequency: always
      type: powershell
      runAs: admin
      content: >-
        Write-Host "powershell::admin::whoami"

        whoami
    - frequency: always
      type: powershell
      runAs: localSystem
      content: >-
        Write-Host "powershell::localSystem::whoami"

        whoami
    - frequency: always
      type: batch
      runAs: admin
      content: >-
        echo "batch::admin::whoami"

        whoami
    - frequency: always
      type: batch
      runAs: localSystem
      content: >-
        echo "batch::localSystem::whoami"

        whoami

After restarting the instance, the scripts above are all being run, but agent.log shows that they all run with system user: Info: Run as: localSystem. Looking at the output of scripts, they all list the whoami value as nt authority\system.

I'm trying to run a script using the Administrator user, but runAs: admin seems to have no affect...

Any help would be greatly appreciated - thanks!!

질문됨 6달 전136회 조회
답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠