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 次
沒有答案

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南