EC2 Cloudformation - userdata using powershell to retrieve powershell scrips from GitHub Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Come Celebrate our 10 Year Anniversary!Am I missing something about pushing a PS script via domain GPODeploy app from github without 2 repos?Cannot push to GitHub from Amazon EC2 Linux instanceDownload single files from GitHub in CloudFormation templateIn Amazon EC2, what's the best way to clone a private github repository on boot?How can I get Jenkins to execute a script that it pulled from Git?Unknown option git config --local reported by JenkinsHow to rename a non-AD computer remotelyWorkflow for developing Cloudformation & Userdata scriptscreating new SSH user in ubuntu ec2 instance using cloudformation template userdata

Why do C and C++ allow the expression (int) + 4*5;

Why complex landing gears are used instead of simple, reliable and light weight muscle wire or shape memory alloys?

What did Turing mean when saying that "machines cannot give rise to surprises" is due to a fallacy?

Vertical ranges of Column Plots in 12

Baking rewards as operations

Random body shuffle every night—can we still function?

My mentor says to set image to Fine instead of RAW — how is this different from JPG?

Why is there so little support for joining EFTA in the British parliament?

Should man-made satellites feature an intelligent inverted "cow catcher"?

Did John Wesley plagiarize Matthew Henry...?

An isoperimetric-type inequality inside a cube

How to resize main filesystem

Where did Ptolemy compare the Earth to the distance of fixed stars?

Determine whether an integer is a palindrome

Flight departed from the gate 5 min before scheduled departure time. Refund options

The Nth Gryphon Number

What is the proper term for etching or digging of wall to hide conduit of cables

Weaponising the Grasp-at-a-Distance spell

What was the last profitable war?

malloc in main() or malloc in another function: allocating memory for a struct and its members

Is a copyright notice with a non-existent name be invalid?

Keep at all times, the minus sign above aligned with minus sign below

Statistical analysis applied to methods coming out of Machine Learning

How to make an animal which can only breed for a certain number of generations?



EC2 Cloudformation - userdata using powershell to retrieve powershell scrips from GitHub



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Come Celebrate our 10 Year Anniversary!Am I missing something about pushing a PS script via domain GPODeploy app from github without 2 repos?Cannot push to GitHub from Amazon EC2 Linux instanceDownload single files from GitHub in CloudFormation templateIn Amazon EC2, what's the best way to clone a private github repository on boot?How can I get Jenkins to execute a script that it pulled from Git?Unknown option git config --local reported by JenkinsHow to rename a non-AD computer remotelyWorkflow for developing Cloudformation & Userdata scriptscreating new SSH user in ubuntu ec2 instance using cloudformation template userdata



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















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 -Forcen",
"Rename-Computer AWSAD10 -restartn",
"Start-Sleep -s 100n",
"$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










share|improve this question






















  • Please clarify "not working". What error messages are you seeing?

    – Matt Houser
    May 15 '16 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.

    – Jenna Shaik
    May 15 '16 at 16:43











  • cloud-init will print to the console (on boot) - you can tell it to log "output: tee -a /var/log/cloud-init-output.log'"

    – Sum1sAdmin
    May 16 '16 at 9:57











  • Do you have internet connectivity on the instance (public IP address or NATted depending on the subnet)?

    – Jukka
    May 16 '16 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

    – Jenna Shaik
    May 17 '16 at 8:43

















0















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 -Forcen",
"Rename-Computer AWSAD10 -restartn",
"Start-Sleep -s 100n",
"$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










share|improve this question






















  • Please clarify "not working". What error messages are you seeing?

    – Matt Houser
    May 15 '16 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.

    – Jenna Shaik
    May 15 '16 at 16:43











  • cloud-init will print to the console (on boot) - you can tell it to log "output: tee -a /var/log/cloud-init-output.log'"

    – Sum1sAdmin
    May 16 '16 at 9:57











  • Do you have internet connectivity on the instance (public IP address or NATted depending on the subnet)?

    – Jukka
    May 16 '16 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

    – Jenna Shaik
    May 17 '16 at 8:43













0












0








0








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 -Forcen",
"Rename-Computer AWSAD10 -restartn",
"Start-Sleep -s 100n",
"$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










share|improve this question














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 -Forcen",
"Rename-Computer AWSAD10 -restartn",
"Start-Sleep -s 100n",
"$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







windows amazon-ec2 amazon-web-services powershell github






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked May 15 '16 at 12:09









Jenna ShaikJenna Shaik

615




615












  • Please clarify "not working". What error messages are you seeing?

    – Matt Houser
    May 15 '16 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.

    – Jenna Shaik
    May 15 '16 at 16:43











  • cloud-init will print to the console (on boot) - you can tell it to log "output: tee -a /var/log/cloud-init-output.log'"

    – Sum1sAdmin
    May 16 '16 at 9:57











  • Do you have internet connectivity on the instance (public IP address or NATted depending on the subnet)?

    – Jukka
    May 16 '16 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

    – Jenna Shaik
    May 17 '16 at 8:43

















  • Please clarify "not working". What error messages are you seeing?

    – Matt Houser
    May 15 '16 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.

    – Jenna Shaik
    May 15 '16 at 16:43











  • cloud-init will print to the console (on boot) - you can tell it to log "output: tee -a /var/log/cloud-init-output.log'"

    – Sum1sAdmin
    May 16 '16 at 9:57











  • Do you have internet connectivity on the instance (public IP address or NATted depending on the subnet)?

    – Jukka
    May 16 '16 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

    – Jenna Shaik
    May 17 '16 at 8:43
















Please clarify "not working". What error messages are you seeing?

– Matt Houser
May 15 '16 at 14:25





Please clarify "not working". What error messages are you seeing?

– Matt Houser
May 15 '16 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.

– Jenna Shaik
May 15 '16 at 16:43





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.

– Jenna Shaik
May 15 '16 at 16:43













cloud-init will print to the console (on boot) - you can tell it to log "output: tee -a /var/log/cloud-init-output.log'"

– Sum1sAdmin
May 16 '16 at 9:57





cloud-init will print to the console (on boot) - you can tell it to log "output: tee -a /var/log/cloud-init-output.log'"

– Sum1sAdmin
May 16 '16 at 9:57













Do you have internet connectivity on the instance (public IP address or NATted depending on the subnet)?

– Jukka
May 16 '16 at 20:02





Do you have internet connectivity on the instance (public IP address or NATted depending on the subnet)?

– Jukka
May 16 '16 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

– Jenna Shaik
May 17 '16 at 8:43





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

– Jenna Shaik
May 17 '16 at 8:43










1 Answer
1






active

oldest

votes


















0














Here is an example how I got it working



"UserData" : "Fn::Base64" : "Fn::Join" : ["", [
"<powershell>n",
"Set-ExecutionPolicy RemoteSigned -Forcen",
"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" -forcen"
"</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:ProgramDataAmazonEC2-WindowsLaunchLog
The actual script is found in C:WindowsTempUserScript.ps1
You will see the default directory the powershell is at the moment of run is C:WindowsTemp ... AWS should update their documentation with info regarding this.






share|improve this answer

























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "2"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f776887%2fec2-cloudformation-userdata-using-powershell-to-retrieve-powershell-scrips-fro%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Here is an example how I got it working



    "UserData" : "Fn::Base64" : "Fn::Join" : ["", [
    "<powershell>n",
    "Set-ExecutionPolicy RemoteSigned -Forcen",
    "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" -forcen"
    "</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:ProgramDataAmazonEC2-WindowsLaunchLog
    The actual script is found in C:WindowsTempUserScript.ps1
    You will see the default directory the powershell is at the moment of run is C:WindowsTemp ... AWS should update their documentation with info regarding this.






    share|improve this answer





























      0














      Here is an example how I got it working



      "UserData" : "Fn::Base64" : "Fn::Join" : ["", [
      "<powershell>n",
      "Set-ExecutionPolicy RemoteSigned -Forcen",
      "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" -forcen"
      "</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:ProgramDataAmazonEC2-WindowsLaunchLog
      The actual script is found in C:WindowsTempUserScript.ps1
      You will see the default directory the powershell is at the moment of run is C:WindowsTemp ... AWS should update their documentation with info regarding this.






      share|improve this answer



























        0












        0








        0







        Here is an example how I got it working



        "UserData" : "Fn::Base64" : "Fn::Join" : ["", [
        "<powershell>n",
        "Set-ExecutionPolicy RemoteSigned -Forcen",
        "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" -forcen"
        "</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:ProgramDataAmazonEC2-WindowsLaunchLog
        The actual script is found in C:WindowsTempUserScript.ps1
        You will see the default directory the powershell is at the moment of run is C:WindowsTemp ... AWS should update their documentation with info regarding this.






        share|improve this answer















        Here is an example how I got it working



        "UserData" : "Fn::Base64" : "Fn::Join" : ["", [
        "<powershell>n",
        "Set-ExecutionPolicy RemoteSigned -Forcen",
        "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" -forcen"
        "</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:ProgramDataAmazonEC2-WindowsLaunchLog
        The actual script is found in C:WindowsTempUserScript.ps1
        You will see the default directory the powershell is at the moment of run is C:WindowsTemp ... AWS should update their documentation with info regarding this.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Aug 29 '17 at 12:51

























        answered Aug 21 '17 at 15:03









        Bogdan PopescuBogdan Popescu

        11




        11



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Server Fault!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fserverfault.com%2fquestions%2f776887%2fec2-cloudformation-userdata-using-powershell-to-retrieve-powershell-scrips-fro%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

            Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

            What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company