1

I have a AWS cloudforamtion - whih build my entire VPC with subnets etc - within this CF builds a windows 2012 server - we want to bootstrap this server under user data so it become a domain controller. All our ps1 scripts are hosted on github. under user data i have entered as below

"<powershell>\n", "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force\n", "Rename-Computer AWSAD10 -restart\n", "Start-Sleep -s 100\n", "$url = \"https://github.com/username/gittest/blob/testinggit/NewAD.ps1\" \n", "(New-Object System.Net.WebClient).DownloadFile($url, 'C:\\Windows\\Temp\\NewAD.ps1')\n", 

the commands to rename the computer works OK - here what is not working the NewAD.PS1 script which is hosted on git - when i run this script on local server all works OK so it promotes to AD by running local however the pull from git is not working - I have also tried:

$trueInvoke-WebRequest -Uri "$trueInvoke-WebRequest -Uri "https://raw.github.com/cloudbase/unattended-setup-scripts/master/UpdateAndSysprep.ps1" \n", 

Any ideas please as I have one week try to figure out how i can do this? and is not much out there how to get this working

5
  • Please clarify "not working". What error messages are you seeing? Commented May 15, 2016 at 14:25
  • Thank you - rename the computer works from above srcript - what is not working - is not pulling or retriving the powershell script from github - so the windows server does not get promoted to active directory - in terms of erros not much i can see on ec2config logs - does not tell me much about the user data - i cant find anywhere how i can see the errors. Commented May 15, 2016 at 16:43
  • 1
    cloud-init will print to the console (on boot) - you can tell it to log "output: {all: '| tee -a /var/log/cloud-init-output.log'}" Commented May 16, 2016 at 9:57
  • Do you have internet connectivity on the instance (public IP address or NATted depending on the subnet)? Commented May 16, 2016 at 20:02
  • instance is on private network so i have a bastion host which i rdp into it and than rdp from there to the instance. instance go via NAT to outbound and is able to browser the link mentioned above to github Commented May 17, 2016 at 8:43

1 Answer 1

1

Here is an example how I got it working

"UserData" : { "Fn::Base64" : { "Fn::Join" : ["", [ "<powershell>\n", "Set-ExecutionPolicy RemoteSigned -Force\n", "Set-Content -Path C:\\OnPremDG.ps1 -Value \"(New-Object System.Net.WebClient).DownloadFile( 'https://download.microsoft.com/download/D/A/1/DA1FDDB8-6DA8-4F50-B4D0-18019591E182/GatewayInstall.exe', 'c:\\GatewayInstall.exe' )`r`n& c:\\GatewayInstall.exe /Q\" -force\n" "</powershell>"]]}} 

Left is a command to run the bloody script :))) (i had it working but lost the command during one of the tests)

Check the log of the scripts at: C:\ProgramData\Amazon\EC2-Windows\Launch\Log The actual script is found in C:\Windows\Temp\UserScript.ps1 You will see the default directory the powershell is at the moment of run is C:\Windows\Temp ... AWS should update their documentation with info regarding this.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.