github.com/hernad/nomad@v1.6.112/e2e/terraform/userdata/windows-2016.ps1 (about)

     1  # Copyright (c) HashiCorp, Inc.
     2  # SPDX-License-Identifier: MPL-2.0
     3  
     4  <powershell>
     5  
     6  # Bring ebs volume online with read-write access
     7  Get-Disk | Where-Object IsOffline -Eq $True | Set-Disk -IsOffline $False
     8  Get-Disk | Where-Object isReadOnly -Eq $True | Set-Disk -IsReadOnly $False
     9  
    10  md "C:\Users\Administrator\.ssh\"
    11  
    12  $myKey = "C:\Users\Administrator\.ssh\authorized_keys"
    13  $adminKey = "C:\ProgramData\ssh\administrators_authorized_keys"
    14  
    15  Invoke-RestMethod `
    16    -Uri "http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key" `
    17    -Outfile $myKey
    18  
    19  cp $myKey $adminKey
    20  
    21  icacls $adminKey /reset
    22  icacls $adminKey /inheritance:r
    23  icacls $adminKey /grant BUILTIN\Administrators:`(F`)
    24  icacls $adminKey /grant SYSTEM:`(F`)
    25  
    26  # for host volume testing
    27  New-Item -ItemType Directory -Force -Path C:\tmp\data
    28  
    29  </powershell>