true true true

How to set Environment Variables on EC2(window) instance via User Data

39 Views Asked by At
<powershell>
$file = $env:SystemRoot + "\Temp\" + (Get-Date).ToString("MM-dd-yy-hh-mm")
New-Item $file -ItemType file
</powershell>
<persist>true</persist>

I did not achieve the expected results using the above code. The expected file was not generated under this path C:\Windows\Temp\ in the instance

1

There are 1 best solutions below

0
xianjie wang On BEST ANSWER

Your instance needs to install EC2Launch,and here is the Revised code:

<powershell> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser -Force $file = $env:SystemRoot + "\Temp\" + (Get-Date).ToString("MM-dd-yy-hh-mm") New-Item $file -ItemType file </powershell> <persist>true</persist>